What is the time complexity of the following Python code snippet? Python def…

PYQ Deloitte Hiring Assessment 2024

What is the time complexity of the following Python code snippet?

Python

def find_duplicates(arr):

duplicates = []

for i in range(len(arr)):

for j in range(i + 1, len(arr)):

if arr[i] == arr[j]:

duplicates.append(arr[i])

return duplicates

  1. A.

    O(n)

  2. B.

    O(log n)

  3. C.

    O(n^2)

  4. D.

    O(1)

Attempted by 220 students.

Sign up free to check your answer

Sign up free

Explore the full course: Cdac C Cat Complete Preparation

Loading lesson…