We want to index each character in alphabet. So ‘a’ = 0, ‘b’ = 1, ‘c’ = 2, ‘d’ = 3…and so on. With this statement we calculate this index. If charAt(i) is ‘a’ then we will get ‘a’ - ‘a’ = 0. This position is now used in array. If charAt(i) = ‘k’. Then ‘k’ - ‘a’ = 10 We get position 10 of array. Does this clear your doubt?
You make it Simple, In this World their are very few people who make things easy You are one of them,
thank you so much
bro I'm speechless! perfect!!
Thank you so much 😀
Concept is clear with the video, please explain the program itself as well, why you are taking int c array or like thi
the solution explains why we need the array. :) do you have a specific doubt? i can help
your explanation is crystal clear..thank you so much bro..
So nice of you
I am able to solve problems because of you
Very detailed explanation.
Great Explanation.
Very detailed explanation. Thank you for your time and insight.
Nice explanation
Thanks and welcome
What an amazing video 🥰
Hae bro
Can u explain
What is Math.abs(i)
it gets the absolute value.
Example:
Math.abs(-1) = 1
Math.abs(1) = 1
int n1{s1.size()};
int n2{s2.size()};
int result{};
vector sr1(26);
vector sr2(26);
for(int i=0; i < n1; ++i)
{
sr1[abs('a'-s1[i])] +=1;
}
for(int i=0; i < n2; ++i)
{
sr2[abs('a'-s2[i])] +=1;
}
for(int i = 0; i < 26; ++i)
{
result += abs(sr2[i]-sr1[i]);
}
return result;
why it's incorrect?
Great video
excellent thank you :)
Thanks
Hi. Just a question here, why are doing (s1.char(i) - 'a' ) here? what is the significance of 'a'. Thanks
We want to index each character in alphabet. So ‘a’ = 0, ‘b’ = 1, ‘c’ = 2, ‘d’ = 3…and so on.
With this statement we calculate this index. If charAt(i) is ‘a’ then we will get ‘a’ - ‘a’ = 0.
This position is now used in array.
If charAt(i) = ‘k’. Then ‘k’ - ‘a’ = 10
We get position 10 of array.
Does this clear your doubt?
@@nikoo28 Yes.. Thanks
bro in which language u explained
this is in JAVA
int makeAnagram(string a, string b) {
int *c = new int(26);
for(int i=0;i
total = total + abs(c[i]) ;
I think you had found the mistake..
.c[s1.charAt(i) - 'a '] ++ ..anyone can explain using for loop ...
HashMap hm= new HashMap();
for(int i=0; i