Guys! Whenever your map or vector will have constant size (like in this question - 26 chars), your space complexity will be O(1). Should have explained this more. Will take it up in future quess! ❤️
The video was very helpful. Pls continue with more String questions! Thank you so much di. Tried one more method with o(n) time and o(1) space complexity. int a_len=a.length(),b_len=b.length(); if(a_len!=b_len) return false; StringBuilder str_a = new StringBuilder(a); StringBuilder str_b = new StringBuilder(b); char ch; int index; for(int i=0;i
I would like to tell you please use little bit hindi in between so all the students can easily able to understand the solution in an easy way .your way of explanation is really awesome
🙋.. one doubt, how the using map sol sc in O(N)? In the map the key always should be in range between 1 to 26 ryt.. so the key can be maximum 26 always. So cant we consider this as O(1)?
Present. Tried all the above methods. In addition, i could do one more method, with o(1) space and O(a+b) time complexity Could get all GFG testcases passed for this solution: public static boolean isAnagram(String a,String b) { int sum=0; for(Character charctr : a.toCharArray()){ sum = sum+charctr; }// end of for loop on first word
for(Character charctr : b.toCharArray()){ sum = sum-charctr; }// end of for loop on second word if(sum == 0){ return true; } return false; } UPDATE: This method will not work because of reasons cited below.
I think it should not work...correct me if I am wrong... Test case on which it should fail is as below : String 1 : az String 2 : by As a+z == b+y in int format, your code will consider this as an anagram
Guys! Whenever your map or vector will have constant size (like in this question - 26 chars), your space complexity will be O(1). Should have explained this more. Will take it up in future quess! ❤️
Mam plz explain the stl in string or bring up a vedio only based on string stl plz it will be reay helpfull.
The video was very helpful. Pls continue with more String questions! Thank you so much di.
Tried one more method with o(n) time and o(1) space complexity.
int a_len=a.length(),b_len=b.length();
if(a_len!=b_len) return false;
StringBuilder str_a = new StringBuilder(a);
StringBuilder str_b = new StringBuilder(b);
char ch;
int index;
for(int i=0;i
Thank you for the string series and keep it up 👍❤
Thanks di for starting the String Series....Please cover all types and all level of questions on string: EASY TO HARD (Till dp) ...Pleaseeeee
was eagerly waiting for video!! thankyou!!
Present.. Well explained!!
array might be good choice as we will not change length of the counter. Great video!
Already knew the approaches yet wanted to revise again thanks for posting
Keep practising ❤️😇
Thanks for the new series
I am really bad at strings and looking forward for this series to make my problem solving skills in strings more strong
Spot on 👍
Good to see you back. Please be consistent. It motivates us to be consistent
Present. thanks for clear explanation
My morning starts with ...watching and practicing this question , again a fab one mam !!
In the first solution where you are comparing string will the time complexity be (nlogn+n) n for relational operation comparison of 2 string?
Yup you are right. But since nlogn is more than n, I just mentioned nlogn. Will be more descriptive next time! Thank you! ❤️
Present ✌👍 your explained very well 👌🏻
I would like to tell you please use little bit hindi in between so all the students can easily able to understand the solution in an easy way .your way of explanation is really awesome
Can the solution/tutorial be in java?
Thank you di...🚀💥
present mam!!
Thank you :)
🙋.. one doubt, how the using map sol sc in O(N)? In the map the key always should be in range between 1 to 26 ryt.. so the key can be maximum 26 always. So cant we consider this as O(1)?
You are right surojit. Map will have max 26 chars so 0(1) space complexity!
Didi XOR s bhi ho jata h yeah...
Yup. Bit manipulation alag se cover karenge! ❤️
Present. Tried all the above methods. In addition, i could do one more method, with o(1) space and O(a+b) time complexity
Could get all GFG testcases passed for this solution:
public static boolean isAnagram(String a,String b)
{
int sum=0;
for(Character charctr : a.toCharArray()){
sum = sum+charctr;
}// end of for loop on first word
for(Character charctr : b.toCharArray()){
sum = sum-charctr;
}// end of for loop on second word
if(sum == 0){
return true;
}
return false;
}
UPDATE: This method will not work because of reasons cited below.
I think it should not work...correct me if I am wrong...
Test case on which it should fail is as below :
String 1 : az
String 2 : by
As a+z == b+y in int format, your code will consider this as an anagram
@@ketanlalcheta4558 Thanks a lot for the insight. Gfg test cases mit not be testing this case.
@@arunkumarmohandas4420 yeah seems so... but great to try different implementation... good effort and makes us think more...
Present 🙂
Present 👍
Present
Didi apki vdosm view nhi aare hai.....apko kuch changes krne chaiye...
Jaise? Open to suggestions
@@codefromscratch-keertipurswani I don't know much about it....but u have to be unique..
@@codefromscratch-keertipurswani just like striver,lovebabbar.....🤞😶
Present