Jul 24, 2021
That is correct. The hash table solution only works when we can assume that all elements are unique in the list. If you want to consider multiple elements, you can keep a seperate count of how many times you have seen the element using the hashmap. Then, you can have a separate check to see if you can reach the target through continous addition. This would be a bit slower than the optimal solution, but would cover the new case, and I believe it would still be better than the naive approach