HasNyen9's blog

By HasNyen9, history, 3 years ago, In English

I get a lot of tips that i should see top coders/programmers code just to get some new information.Indeed,I get a lot of new information but I dont understand some specific part of their code,like how's that working.Is there any way to know that? As an example,look at this code:

int n;
cin>>n;
string s;
cin>>s;
int count[26]{0};
for(int i=0;i<n;i++)
  count[s[i]-'a']=1; //here i dont get the logic behind this part.I know what its doing.But i dont know how it is doing it.
  • Vote: I like it
  • +1
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

At first, you should try to understand what each variable means and it would give you some idea.

»
3 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Dry run tough test case on a piece of paper.