AWS 前端店面

Given a string return a reduced string such that , the reduced string has the characters re-arranged

  1. in order of characters having highest frequencey
  2. followed by character which appears just once in the same order as in the original string
  3. and no duplicate characters

e.g. Give String :- hello world
Return:- lohe wrd

Explaination :- ‘l’ appears thrice, ‘o’ appears twice, ‘h’,‘e’, ’ '(space) ,‘w’,‘r’,‘d’ all appear once
‘h’,‘e’,‘w’,‘r’,‘d’ should be appended in the same order as they appear in the original string hello world

用 javascript 做