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; } }
@codestorywithMIK15 күн бұрын
Yep 😇. Thank you for sharing ❤️❤️❤️
@aws_handles15 күн бұрын
Thanks 👌🏻
@FanIQQuiz15 күн бұрын
I did same
@HumanBeing-m1x15 күн бұрын
@@codestorywithMIK please make video on manacher's algorithm, z algorithm, rabin karp please dont ignore the request
@gui-codes15 күн бұрын
same as Leetcode-392 I got badge of 365 days and also got Leetcode Tshirt after long wait. Thank you for making me consistent.
@firozkamdar673515 күн бұрын
Good for you, i am not even half to purchasing it(T-Shirt)
@MUHAMMADABDULLAH-t6e1g14 күн бұрын
Salute to you sir! you are a legend! hats off!
@_PRANAYMATE15 күн бұрын
Bro solved on my own ,, After completing your strings playlist I feel confident in strings
@amanpaliwalvlogs686014 күн бұрын
Radhe Radhe ❤ sirji
@manishjoshi973714 күн бұрын
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 🥰🥰🥰
@codestorywithMIK14 күн бұрын
Many Many Congratulations🎊🎊🎉🎉❤️ Very happy to hear this. And Thank you for your kind words 😇🙏
@manishjoshi973714 күн бұрын
@ 🥰🥰
@bhupendrakalal172715 күн бұрын
sir mod le kr kr diya tha ,baki same approach use kri 😇😇😇
@sumatheultimategirl747715 күн бұрын
Thank you so much for making these videos
@codestorywithMIK15 күн бұрын
🙏❤️
@MohammedHasmi57715 күн бұрын
Amazing video sir
@ramuchintala733915 күн бұрын
nice thought process brother
@hare_krishna841115 күн бұрын
bhaiya raadhe radhee ❤
@codestorywithMIK15 күн бұрын
Radhe Radhe 😇❤️🙏
@hackingkingdom563415 күн бұрын
my plan is learn more about Golang and on projects and AWS also
@HumanBeing-m1x15 күн бұрын
please make video on manacher algorithm for longest palindrome string and also make video on z algorithm
@dayashankarlakhotia494315 күн бұрын
First 🎉❤ and also get badges of 365 leetcode 🎉❤
@adarshjha512615 күн бұрын
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-codes15 күн бұрын
@@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 ?
@codestorywithMIK15 күн бұрын
@@adarshjha5126 Wow. Many Many Congratulations. Sure, I will hide your name 🙂
@codestorywithMIK15 күн бұрын
Awesome @dayashankarlakhotia4943. Way to go. You have been consistent since a long time. Keep it up.
@adarshjha512615 күн бұрын
@@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 😊💪
@FanIQQuiz15 күн бұрын
Easy one ☝️
@Authenticbharatiya15 күн бұрын
bhaiya i want to learn full stack dev using mern what's the best source to learn? like some course or anything?
@rahuljeena15 күн бұрын
We can perform that changing operation only once but u are performing in every index. Can u pls explain!
@codestorywithMIK15 күн бұрын
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.
@mightytitan171915 күн бұрын
MIK what setup you use while making these videos ? which tablet,which laptop etc etc?
@codestorywithMIK15 күн бұрын
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
@mightytitan171914 күн бұрын
@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
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; } };❤❤
@skid817415 күн бұрын
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)
@TechHaiko15 күн бұрын
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
@TechHaiko15 күн бұрын
Time complexity : O(n)
@saurabh006515 күн бұрын
class Solution { public: bool canMakeSubsequence(string str1, string str2) { int i=0,j=0; int cnt=0; while(i
@Coder_Buzz0715 күн бұрын
❤❤
@AryanVats60315 күн бұрын
my code sir!! bool canMakeSubsequence(string str1, string str2) { int i=0,j=0; while(i
@masterLight31315 күн бұрын
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); } };
@masterLight31315 күн бұрын
It seems memoization will not happen as its linear, will go ahead with greedy
@masterLight31315 күн бұрын
Working solution: bool canMakeSubsequence(string str1, string str2) { int m = str1.size(), n = str2.size(); int j=0; for(int i=0; i
@thejasgowda628215 күн бұрын
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])