You can use String.indexOf method to find the substring in a given string. *Java Code* if(s.length() != goal.length()) return false; String t = s + s; if(t.indexOf(goal) != -1) return true; return false;
Please make a video on leetcode 3337. It was the 5th problem in leetcode weekly 421. for me it is very hard to understand that problem from leetcode comments. Also there is no proper explanation of that problem on yt + It is from an advanced topic (matrix exponentiation)
Bhaiya left shift mein n^2 lag raha tha, isiliye mene right shift Kiya Tha, aur after one right shift check Kar raha hu, ki same hai ki nhi, aur solved ho gaya
@Billy-gd1rm bhai dekh npos string class ka ek constant member hai , Jo ki ye darshata hai ki kya koi aise value jo string me na present ho (Mota Moti ye pata rakho ki jab bhi hm string me search kar rhe hai to ye darshata hai ki vo value string me present hai ki nhi ) Waise ye static finte large value hote hai But itna hi pata rakho that enough
@@Billy-gd1rm bhai dekho love babbar (Agar pure beginner ho ) and if comfortable ho thoda sa ho for (striver +code story with mik ) Bus itna 🙂 Isse jyada no required any paid course Logic building ke liye hackerrank try kar sakte ho
Normal nahi expert banna hai ❤💯
Expert nahi legend ultra pro banana hain
I want to be like you MIK.
travelling + studying + desciplied etc. you manage everything well.
I used this approach, it's cool that it worked..
class Solution {
public boolean rotateString(String s, String goal) {
String combined = s + s;
if(goal.length() < s.length()){
return false;
}
if(combined.indexOf(goal) != -1){
return true;
}
return false;
}
}
Binge watching all your playlists. They are too good.
Thanks a lot
Expert banna Hai 😊❤
love you. thanks a lot mik for improving my problem solving skills
yes sir i remember 2nd approach aapne batai thi purnai video me ,btw thank you for great explanation❤❤❤❤
class Solution {
public:
bool rotateString(string s, string goal) {
int n = s.size();
for(int i = 0; i
time complexity is O(N square) not O(N) because "s.erase(0, 1);" will take O(N) time complexity every time
@@AkOp-bf9vm Yes, Bro you are right.
Hii, aap kon sa writing pad use krte ho? any suggestions?
Thanks a lot MIK. Always learning from you.
How do you think, Mindblowing...
Love you bro ❤
class Solution {
public:
bool rotateString(string s, string goal) {
if(s.size() > goal.size()) return false;
string ans = s;
ans += s;
if(ans.find(goal) < ans.length()) return true;
return false;
}
};
You can use String.indexOf method to find the substring in a given string.
*Java Code*
if(s.length() != goal.length()) return false;
String t = s + s;
if(t.indexOf(goal) != -1) return true;
return false;
Please make a video on leetcode 3337. It was the 5th problem in leetcode weekly 421. for me it is very hard to understand that problem from leetcode comments. Also there is no proper explanation of that problem on yt + It is from an advanced topic (matrix exponentiation)
best explanantion
Sir i am big fan of you🎉❤
Thanks a lot always ❤
Bhaiya left shift mein n^2 lag raha tha, isiliye mene right shift Kiya Tha, aur after one right shift check Kar raha hu, ki same hai ki nhi, aur solved ho gaya
Ye yaad kaise rahega ...agar in future pta v lg jaye esa kuch use krna h
class Solution {
public:
bool rotateString(string s, string goal) {
if(s.size()!=goal.size())return false;
string check=s+s;
if(check.find(goal)==-1){
return false;
}
return true;
}
};
bool rotateString(string s, string goal) {
if(s.size()>goal.size()) return false;
string str=s+s;
if(str.find(goal)!=string ::npos) return true;
return false;
} My solution in c++
Bhai yeh npos kya hota hn 4 line samjhana
@Billy-gd1rm bhai dekh npos string class ka ek constant member hai ,
Jo ki ye darshata hai ki kya koi aise value jo string me na present ho (Mota Moti ye pata rakho ki jab bhi hm string me search kar rhe hai to ye darshata hai ki vo value string me present hai ki nhi )
Waise ye static finte large value hote hai
But itna hi pata rakho that enough
@ShashankShekharShukla-xw7rc bhai aap dsa kaha se kr rhe hoo ? Please tell
@@ShashankShekharShukla-xw7rc please tell bhai
@@Billy-gd1rm bhai dekho love babbar (Agar pure beginner ho ) and if comfortable ho thoda sa ho for (striver +code story with mik )
Bus itna 🙂
Isse jyada no required any paid course
Logic building ke liye hackerrank try kar sakte ho
What Software , You Use For Making Videos ?
Apple notes
@@divyanshuvashu481 thanks !
1st bro thank you
not so optimized but here's my solution
class Solution {
public:
bool rotateString(string s, string goal) {
int n=s.length();
string newS=s;
string out="";
while(out!=s){
out=newS[n-1]+newS.substr(0,n-1);
if(out==goal){
return true;
}
newS=out;
}
return false;
}
};
return s.size() == g.size() && (s+s).find(g) != -1;
Thanks bro👏🏻