Feedback on Hashmap Based Solution?

def search_triplets(arr):
  triplets = set()
  num_map = set(arr)

  for left_idx, l_num in enumerate(arr):
    for right_idx, r_num in enumerate(arr[left_idx+1:]):
      target = 0 - l_num - r_num
      if target in num_map and target != l_num and target != r_num:
        triplets.add(tuple(sorted([l_num, target, r_num])))

  return [list(e) for e in triplets]

Type your question above this line.


Hi @Akshay_Goel
Great job👍🏻, Thank you for sharing it with us.