Code not working, has doubt inside for loop


what should be inside for loop, i am not able to understand it.

Check this.

it is working fine now but can you please tell why count[str[i]]++ ? i am not getting the logic behind that

count[str[i]]++
means for character at str[i] its frequency is incremented by 1. The array will expect its index to be an integer but you may think that str[i] is a character. Yes str[i] is a character but in count[str[i]]++ compiler will treat str[i] with its ascii value which is an integer(which ranges from 0-255).
So if str[i]==β€˜a’. Knowing that acii value of β€˜a’ is 97.
count[str[i]]++ will actually be count[97]++

It’s clear now, Thanks