Yes in the index we are getting index value like c is the 3 alphabet of English so we will store it on the 3rd index and if we are getting same in the 2nd string then we will do minus then if it will become 0 it means both are other both are different if both are different then it's not anagram. I hope you will get some clarity with this.
@Pragya Parmar Here the ASCII value of a is 97 and so when you will do charAt(i)-'a' then it will give you the correct position of any character. E.g. suppose charAt(i) is give m so m-a here ASCII value of m is 109 and ASCII value of is 97 so 109-97= 12 which is the correct index of m according to alphabet. I hope you are able to understand now.
Thanks bro it was confusing at the start but u exampled it very well🥰
New Approach buddy .
Brother good code but i have small doubt at index . Can you explain that some more clearly there ... ?
Yes in the index we are getting index value like c is the 3 alphabet of English so we will store it on the 3rd index and if we are getting same in the 2nd string then we will do minus then if it will become 0 it means both are other both are different if both are different then it's not anagram.
I hope you will get some clarity with this.
thanks for the effort !
🥰
good work.
Bro in a test case it is showing that index out of bounds
a kyu add kyu?
isse achha to string to array mein convert karo fir sort kar k every element compare karo
Why charAt(i)-a???
Here charAt(i)-'a' will give you the correct position like in alphabet a comes on 1st position so it will give us 1
@@techpathak3617 mai ni smjhi 'a' q minus kara...mtlb 'a' hi q and aap bole c-a krenge to 3 mil jaega mtlb?
@Pragya Parmar
Here the ASCII value of a is 97 and so when you will do charAt(i)-'a' then it will give you the correct position of any character.
E.g. suppose charAt(i) is give m so
m-a here ASCII value of m is 109 and ASCII value of is 97 so 109-97= 12 which is the correct index of m according to alphabet.
I hope you are able to understand now.
@@techpathak3617 haa mai smjh gyi
Thank you so much ❤️
@@techpathak3617 actually m in 13th position and your ans is 12th