Here’s a simple algorithm:
- Create an empty
intarray of length
26, it will be initialized with
- Iterate your String
- Get the
charat the current index.
- Tricky part: You need a mapping between a given
charand its corresponding index (e.g.
awould be index
bwould be index
1and so on). Have a look at an ASCII-Table for this
- Add 1 to the element at the mapped index of the created array.
- At the end, iterate the array and only print the values that are not
0along with the corresponding
charat that index (Need the ASCII mapping again here)