We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
suppose s[i]=99 and 'a'= 97 (since the ascii code of a =97). so, small[s[i]-'a'] = small[99-97] =small[2].
i.e, if s[i]=c ( which is 3rd alphabet if u start counting from zero and its ascii code is 99) then small[2] will be computed.
a better way to understand is small[0] will store entries of 'a', small[1] will store entries of 'b' and so on.
Hope it's helpful!
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Pangrams
You are viewing a single comment's thread. Return to all comments →
suppose s[i]=99 and 'a'= 97 (since the ascii code of a =97). so, small[s[i]-'a'] = small[99-97] =small[2]. i.e, if s[i]=c ( which is 3rd alphabet if u start counting from zero and its ascii code is 99) then small[2] will be computed. a better way to understand is small[0] will store entries of 'a', small[1] will store entries of 'b' and so on. Hope it's helpful!