Chargebee interview question

Program in ide: Input - wwwaabbc Output - w3a2b2c1

Interview Answers

Anonymous

28 Feb 2022

Put the char as keys in a map and increase the count if occurring multiple time. Then print the map key and value.

1

Anonymous

5 Apr 2022

def reverse(tuples): k='' s =[] for i in tuples: if i not in s: if tuples.count(i)>=1: s.append(i) s = ''.join(s) print(s) for i in s: m = tuples.count(i) k+=i+str(m) return k print(reverse('wwwaabbc'))