Make String a Subsequence Using Cyclic Increments | Leetcode 2825

  Рет қаралды 2,418

Techdose

Techdose

Күн бұрын

Пікірлер: 13
@kingraj4797
@kingraj4797 10 күн бұрын
Well said sir, In one go I have solved this problem keep going with this brief explanation sir..
@techdose4u
@techdose4u 10 күн бұрын
Great 👍
@vikasvoruganti7490
@vikasvoruganti7490 11 күн бұрын
class Solution { public: bool canMakeSubsequence(string str1, string str2) { int n1=str1.size(); int n2=str2.size(); int j=0; for(int i=0;i
@mayukhbhowmik934
@mayukhbhowmik934 10 күн бұрын
I feel your this solution in little bit of overwhelming....I tried Simply over two pointer approach:class Solution { private: bool Check(char x, char y) { // Check if x matches y directly or can transform into y by incrementing return (x == y || (x + 1 - 'a') % 26 + 'a' == y); } public: bool canMakeSubsequence(string str1, string str2) { int first = 0, second = 0; // Edge Case: If str1 is shorter than str2, it's impossible if (str1.length() < str2.length()) return false; // Two-pointer technique while (first < str1.length() && second < str2.length()) { if (Check(str1[first], str2[second])) { first++; second++; } else { first++; } } // If we traversed all of str2, it's possible to form it return second == str2.length(); } };
@sailendrachettri8521
@sailendrachettri8521 10 күн бұрын
Thank you sir :)
@techdose4u
@techdose4u 10 күн бұрын
welcome :)
@letsk9188
@letsk9188 11 күн бұрын
Thanks ❤
@techdose4u
@techdose4u 10 күн бұрын
welcome :)
@bharat_india12
@bharat_india12 11 күн бұрын
bool canMakeSubsequence(string str1, string str2) { if(str2.size()>str1.size()) return false; int i=0,j=0; while(i
@Sen-d9d
@Sen-d9d 10 күн бұрын
I solve the java code with your code is accepted but if we have to submit it shows run time error messge
@techdose4u
@techdose4u 10 күн бұрын
maybe try correcting using some dry run
@yashbhoomkar5027
@yashbhoomkar5027 11 күн бұрын
the problem also states "use the operation at most once" how did you handle that statement in your solution??
@techdose4u
@techdose4u 10 күн бұрын
It doesnt matter for how many indices you do coz you can parrallely do every increment at once for only for 1 time :)
Maximum Average Pass Ratio | Leetcode 1792
18:37
Techdose
Рет қаралды 1 М.
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 35 МЛН
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 119 МЛН
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 16 МЛН
Move Pieces to Obtain a String | Leetcode 2337
19:53
Techdose
Рет қаралды 5 М.
How I Mastered Data Structures and Algorithms in 8 Weeks
15:46
Aman Manazir
Рет қаралды 127 М.
Minimum Limit of Balls in a Bag | Leetcode 1760
22:31
Techdose
Рет қаралды 4,8 М.
Special Array II | Leetcode 3152
13:49
Techdose
Рет қаралды 4,2 М.
Reality of my Google Salary after TAXES
6:54
Fraz
Рет қаралды 265 М.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 897 М.
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 35 МЛН