Ad
  • Default User Avatar

    I don't think I would count this as a Best Practice answer seeing this would run in O(n^2) time. You can achieve O(n) time using a dictionary.