Leetcode 2486 Append Characters to String to Make Subsequence | Hindi

preview_player
Показать описание
2486. Append Characters to String to Make Subsequence | Hindi
Leetcode 2486. Append Characters to String to Make Subsequence
2486 Append Characters to String to Make Subsequence
2486. Append Characters to String to Make Subsequence
Leetcode 2486. Append Characters to String to Make Subsequence
Leetcode contest 321
today's leetcode contest 321
Append Characters to String to Make Subsequence
leetcode 2486 hindi


leetcode Append Characters to String to Make Subsequence
Leetcode contest 321 2nd problem

Leetcode 2486 todays leetcode contest Question
Leetcode 2486 leetcode contest 316 Question
Leetcode 2486 Append Characters to String to Make Subsequence

🔴 Do check out my channel for "Daily Leetcode Challenges" and playlists for "DSA and leetcode contests" :

Weekly Contest 297 playlist:

Weekly Contest 296 playlist:

🔴 Connect with me here:

-----------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------Link to Other videos :

Leetcode Contest 289 | 2244. Minimum Rounds to Complete All Task :
Leetcode Contest 289 | Hard Problem : 2246. Longest Path With Different Adjacent Characters :

Gadgets I use:
For my coding videos:
Рекомендации по теме
Комментарии
Автор

Please dont forget to subscribe. Comment down below if you need solutions for rest of the problems of the contest. 🙂🙂

Think_Code
Автор

A small correction for a test case:
"abcde"
"a"
you have to add a condition....
public int appendCharacters(String s, String t) {
int i=0;
int j=0;
while(i<s.length() && j<t.length()){
while(i<s.length() && s.charAt(i)!=t.charAt(j)){
i++;
}
if(i==s.length()){
return t.length()-j;
}
i++;
j++;
}
return t.length()-j;
}
As j should need to check wheather its less than t.length() so that we can overcame from Runtime Error for the given above test case

HamzaKhan-uvdc
Автор

Code :
class Solution {
public:
int appendCharacters(string s, string t) {

int i=0;
int j=0;

while(i<s.size() && j<t.size()){
while(i<s.size() && s[i]!=t[j]){
i++;
}
if(i==s.size()){
return t.size()-j;
}
i++;
j++;
}

return t.size()-j;

}
};

Think_Code
visit shbcf.ru