Make String a Subsequence Using Cyclic Increments | Similar Problem |Leetcode 2825 |codestorywithMIK

  Рет қаралды 4,670

codestorywithMIK

codestorywithMIK

Күн бұрын

Пікірлер: 51
@aizad786iqbal
@aizad786iqbal 15 күн бұрын
we could have used mod also no need to handle corner case then class Solution { public boolean canMakeSubsequence(String str1, String str2) { int m = str1.length(); int n = str2.length(); if (n > m) { return false; } int i = 0; int j = 0; while (i < m && j < n) { if ((str1.charAt(i) % 26 == str2.charAt(j) % 26) || ((str1.charAt(i) + 1) % 26 == str2.charAt(j) % 26)) { j++; } i++; } return j == n; } }
@codestorywithMIK
@codestorywithMIK 15 күн бұрын
Yep 😇. Thank you for sharing ❤️❤️❤️
@aws_handles
@aws_handles 15 күн бұрын
Thanks 👌🏻
@FanIQQuiz
@FanIQQuiz 15 күн бұрын
I did same
@HumanBeing-m1x
@HumanBeing-m1x 15 күн бұрын
@@codestorywithMIK please make video on manacher's algorithm, z algorithm, rabin karp please dont ignore the request
@gui-codes
@gui-codes 15 күн бұрын
same as Leetcode-392 I got badge of 365 days and also got Leetcode Tshirt after long wait. Thank you for making me consistent.
@firozkamdar6735
@firozkamdar6735 15 күн бұрын
Good for you, i am not even half to purchasing it(T-Shirt)
@MUHAMMADABDULLAH-t6e1g
@MUHAMMADABDULLAH-t6e1g 14 күн бұрын
Salute to you sir! you are a legend! hats off!
@_PRANAYMATE
@_PRANAYMATE 15 күн бұрын
Bro solved on my own ,, After completing your strings playlist I feel confident in strings
@amanpaliwalvlogs6860
@amanpaliwalvlogs6860 14 күн бұрын
Radhe Radhe ❤ sirji
@manishjoshi9737
@manishjoshi9737 14 күн бұрын
bhaiya i got placed in CAMS from iit guwahati campus recruitment drive ... All thanks to your guidance and learnings, I've been following u since january 2024..You r great bhaiya 🥰🥰🥰
@codestorywithMIK
@codestorywithMIK 14 күн бұрын
Many Many Congratulations🎊🎊🎉🎉❤️ Very happy to hear this. And Thank you for your kind words 😇🙏
@manishjoshi9737
@manishjoshi9737 14 күн бұрын
@ 🥰🥰
@bhupendrakalal1727
@bhupendrakalal1727 15 күн бұрын
sir mod le kr kr diya tha ,baki same approach use kri 😇😇😇
@sumatheultimategirl7477
@sumatheultimategirl7477 15 күн бұрын
Thank you so much for making these videos
@codestorywithMIK
@codestorywithMIK 15 күн бұрын
🙏❤️
@MohammedHasmi577
@MohammedHasmi577 15 күн бұрын
Amazing video sir
@ramuchintala7339
@ramuchintala7339 15 күн бұрын
nice thought process brother
@hare_krishna8411
@hare_krishna8411 15 күн бұрын
bhaiya raadhe radhee ❤
@codestorywithMIK
@codestorywithMIK 15 күн бұрын
Radhe Radhe 😇❤️🙏
@hackingkingdom5634
@hackingkingdom5634 15 күн бұрын
my plan is learn more about Golang and on projects and AWS also
@HumanBeing-m1x
@HumanBeing-m1x 15 күн бұрын
please make video on manacher algorithm for longest palindrome string and also make video on z algorithm
@dayashankarlakhotia4943
@dayashankarlakhotia4943 15 күн бұрын
First 🎉❤ and also get badges of 365 leetcode 🎉❤
@adarshjha5126
@adarshjha5126 15 күн бұрын
Hi mik bhai.... Aapke potd solutions ne meri bohot help ki Goldman Sachs ke internship opportunity Milne me..❤ U r truly a gem 💎 Please hide my name if u upload the screenshot of the post 😂😅
@gui-codes
@gui-codes 15 күн бұрын
@@adarshjha5126 Congrats bhai. Can you please share your preparation strategy ? I am planning to apply for Product based company. Did they ask OS, DBMS etc as well ?
@codestorywithMIK
@codestorywithMIK 15 күн бұрын
@@adarshjha5126 Wow. Many Many Congratulations. Sure, I will hide your name 🙂
@codestorywithMIK
@codestorywithMIK 15 күн бұрын
Awesome @dayashankarlakhotia4943. Way to go. You have been consistent since a long time. Keep it up.
@adarshjha5126
@adarshjha5126 15 күн бұрын
@@gui-codessure, Focus on DSA the most and also some non standard problems as well and just explain your approach to the interviewer in depth... Apart from that Core subjects are also very important which will be covered if you learn it during your college exam preparation... Then is having a good projects...it will balance out if you are not very good in DSA like expert on CF.. Last is luck 🤞 and beleive in God and youself 😊💪
@FanIQQuiz
@FanIQQuiz 15 күн бұрын
Easy one ☝️
@Authenticbharatiya
@Authenticbharatiya 15 күн бұрын
bhaiya i want to learn full stack dev using mern what's the best source to learn? like some course or anything?
@rahuljeena
@rahuljeena 15 күн бұрын
We can perform that changing operation only once but u are performing in every index. Can u pls explain!
@codestorywithMIK
@codestorywithMIK 15 күн бұрын
The problem asks that we can pick a set of indices . So, in one complete iteration, whichever indices i chose to change are complete set of indices i chose.
@mightytitan1719
@mightytitan1719 15 күн бұрын
MIK what setup you use while making these videos ? which tablet,which laptop etc etc?
@codestorywithMIK
@codestorywithMIK 15 күн бұрын
Hi there, I honestly don’t have any setup. Because I am travelling most of the time. So I prefer only an ipad , apple pencil. I don’t use mic. Just the default mic of ipad. ipad - ipad 11 pro Apple pencil 3rd gen
@mightytitan1719
@mightytitan1719 14 күн бұрын
@codestorywithMIK thank you for this Can you give us tips or make a video on how to answer questions in interview , how to name variable , how to explain them as sometimes they make us write in notepad and I can't draw figure to explain them ,it will be really helpful And thank you for doing the noble job,the way you explain is incredible
@thefinalfit
@thefinalfit 15 күн бұрын
Done 🎉
@Madaraa777
@Madaraa777 15 күн бұрын
class Solution { public: bool canMakeSubsequence(string str1, string str2) { int i=0, j=0; while(i < str2.size() && j < str1.size()){ if(str2[i] == str1[j] || (((str1[j]-'a'+1)%26)+'a') == str2[i]){ i++; } j++; } return i == str2.size(); } };
@167_sashreek_das5
@167_sashreek_das5 15 күн бұрын
my target is to crack apple inc
@shubhamsahay5806
@shubhamsahay5806 15 күн бұрын
class Solution { public: bool canMakeSubsequence(string str1, string str2) { int n = str1.size(); int m = str2.size(); int i = 0; int j = 0; while(i < n && j < m){ char ch1 = str1[i]; char ch2 = str2[j]; if(ch2 == 'a' + ((ch1 - 'a' + 1) % 26) || ch1 == ch2){ j++; } i++; } return j == m; } };❤❤
@skid8174
@skid8174 15 күн бұрын
Can anyone provide optimal solution for this problem asked in tcs mockvita (DP) Minimize Cost to Form String X from Y You are given two strings: X and Y, and two integers A and B. Your task is to form the string X using substrings from Y, and the cost of each substring depends on whether you take it from Y or its reverse. The cost of taking substrings from Y or reverse(Y) is different: Substrings of Y cost A per substring. Substrings of reverse(Y) cost B per substring. You need to determine the minimum cost to form the string X using substrings from Y or its reverse. If it is impossible to form X using any combination of substrings from Y or reverse(Y), return -1. Input: A string X of length m. A string Y of length n. Two integers A and B, where: A is the cost per substring taken from Y. B is the cost per substring taken from reverse(Y). Output: Return the minimum cost to form the string X using substrings from Y and reverse(Y). If it is impossible to form X, return -1. Example 1: Input: X = "abc", Y = "aabbcc", A = 3, B = 5 Output: 6 Explanation: You can form "abc" by taking the substring ab from Y (cost = A = 3) and c from Y (cost = A = 3). Thus, the total cost is 3 + 3 = 6. Example 2: Input: X = "xyz", Y = "zyx", A = 2, B = 4 Output:4 Explanation: You can form "xyz" by taking the entire reverse(Y) ("zyx") as a substring. The cost is B = 4. Example 3: Input: X = "abc", Y = "xyz", A = 3, B = 5 Output:-1 Explanation: It is impossible to form the string "abc" from Y or reverse(Y) because none of the characters in "abc" are present in Y or its reverse. Constraints: 1 ≤ m, n ≤ 10000 (length of strings) 0 ≤ A, B ≤ 1000 (cost values)
@TechHaiko
@TechHaiko 15 күн бұрын
class Solution { public: bool canMakeSubsequence(string str1, string str2) { int i=0; int j=0; int n=str1.size(); int m=str2.size(); while(i
@TechHaiko
@TechHaiko 15 күн бұрын
Time complexity : O(n)
@saurabh0065
@saurabh0065 15 күн бұрын
class Solution { public: bool canMakeSubsequence(string str1, string str2) { int i=0,j=0; int cnt=0; while(i
@Coder_Buzz07
@Coder_Buzz07 15 күн бұрын
❤❤
@AryanVats603
@AryanVats603 15 күн бұрын
my code sir!! bool canMakeSubsequence(string str1, string str2) { int i=0,j=0; while(i
@masterLight313
@masterLight313 15 күн бұрын
Just tried like below but last 10 cases giving TLE: class Solution { public: vector dp; char getNext(char ch) { return 'a' + (ch - 'a' + 1) % 26; } bool helper(string s1, string s2, int m, int n) { if(n == 0) return true; if(m == 0) return false; if(dp[m-1][n-1] != -1) return dp[m-1][n-1]; if(s1[m-1] == s2[n-1] || getNext(s1[m-1]) == s2[n-1]) { return dp[m-1][n-1] = helper(s1, s2, m-1, n-1); } return dp[m-1][n-1] = helper(s1, s2, m-1, n); } bool canMakeSubsequence(string str1, string str2) { int m = str1.size(), n = str2.size(); dp.resize(m, vector(n, -1)); return helper(str1, str2, m, n); } };
@masterLight313
@masterLight313 15 күн бұрын
It seems memoization will not happen as its linear, will go ahead with greedy
@masterLight313
@masterLight313 15 күн бұрын
Working solution: bool canMakeSubsequence(string str1, string str2) { int m = str1.size(), n = str2.size(); int j=0; for(int i=0; i
@thejasgowda6282
@thejasgowda6282 15 күн бұрын
this is my approach - bool canMakeSubsequence(string str1, string str2) { int i = 0, j = 0; while (i < str1.size() && j < str2.size()) { char c = str1[i]; if (c == 'z' && str2[j] == 'a') j++; if (abs(c - str2[j])
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
Knuth-Morris-Pratt KMP String Matching Algorithm | Search Pattern | GFG POTD
1:05:36
Count Inversions in an Array | Brute and Optimal
24:17
take U forward
Рет қаралды 252 М.
React 19 is now stable! - What's new in React 19
16:53
Piyush Garg
Рет қаралды 31 М.
Move Pieces to Obtain a String | Leetcode 2337
19:53
Techdose
Рет қаралды 5 М.
Mediocrity is Rising | Raw and real talk before 2024 ends.
20:40
Harkirat Singh
Рет қаралды 299 М.
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН