Linear Search performs better than HashMap+binary search to retrieve an object satisfying a condition I was trying out this problem link.