Ad
  • Default User Avatar

    I'm with you. The question is very poorly phrased. If you notice the {} in the expected values you might think of a dictionary. And you'd be right. So just return a dictionary. It's pretty stupid.

  • Default User Avatar

    The actual algorithmic part of this question is not very difficult, but I have a problem getting the return type to be correct. How do I return an object the way that the question wants? My understanding was that returning an object does something like " object at instance, etc".

  • Default User Avatar

    This is true but it is not the only reason it is not optimal. As the comment above yours said, sorting takes klog k time (where k is the length of a word) which means that the total runtime will be n*klogk. Using a dictionary, for example, will only take nk time.

  • Default User Avatar

    Yea this answer is defintiely not correct. A counter example is ['n','n','n','n','s','s','s','e','w','w']