I recently attended a tech interview round 1. Where the interviewer asked this question. It seemed like an easy problem to me But took me 30+ minutes to solve it. My LC count is 400+. But I still took 30+ minutes to solve it. I just wanted to see how much time does others take to solve it. I would love it if you can clock your time while trying to solve this question and share it in the comments If you find it medium or easy and how long it took.
Question:
-------------------------------------------------
Given a array of strings like : ["$", "$$", "$$", "$", "$$", "$$", "$$", "$", "$"]
print result array as : [1, 1.1, 1.2, 2, 2.1, 2.2, 2.3, 3, 4]
Note: 1<=length of string <=2
--------------------------------------------------
Follow up:
max string length is dynamic.
example:
array of strings : ["$", "$$$", "$$$$", "$", "$$$", "$$$", "$$$", "$", "$", "$$", "$$", "$$$", "$$"]
result array : [1, 1.1.1, 1.1.1.1, 2, 2.1.1, 2.1.2, 2.1.3, 3, 4, 4.1, 4.2, 4.2.1, 4.3]
Note: 1<=length of string <=10^4
--------------------------------------------------Thank you.