C++ programing code counts[s[i] - '0'] ++; -
for (int = 0; < s.length(); i++) { if (isdigit(s[i])) counts[s[i] - '0'] ++; }
what code means, 1 can able explain code " counts[s[i] - '0'] ++;" exact opertion
counts
ten-element array, being used count how many times each digit appears in s
.
specifically:
s[i] - '0'
turns'0'
0
,'1'
1
etc.counts[...]++
increments corresponding element of array.
Comments
Post a Comment