DSAAGP384 - Editorial

Problem Link - Duplicate Integers in Arrays

Problem Statement:

Given N non-negative integers, check if there is any duplicate value present.

Approach:

  • Used vectors instead of arrays.
  • For each element A_i, we traverse through the array to check if there is any duplicate value.
  • If we find any duplicate value we return “YES” otherwise “NO”.

Complexity:

  • Time Complexity: O(N^2) Using a nested loop to check for each element duplicate value.
  • Space Complexity: O(1) No extra space is used.