Solve Leetcode Problems and Get Offers From Your Dream Companies

Nil Madhab
LeetCode Simplified
2 min readJan 30, 2021

--

Leetcode 442: Find All Duplicates in an Array

In this series, I am going to solve Leetcode medium problems live with my friends, which you can see on our youtube channel, Today we will do Problem Leetcode 442: Find All Duplicates in an Array.

A little bit about me, I have offers from Uber India and Amazon India in the past, and I am currently working for Booking.com in Amsterdam.

Motivation to learn algorithms

Problem Statement

Given an array of integers, 1 ≤ a[i] ≤ n (n = size of the array), some elements appear twice and others appear once.

Find all the elements that appear twice in this array.

Could you do it without extra space and in O(n) runtime?

Example:

Input:
[4,3,2,7,8,2,3,1]
Output:
[2,3]

Youtube Discussion

--

--

Nil Madhab
LeetCode Simplified

Developer @Booking.com | ex: Samsung, OYO | IIT Kharagpur | Entrepreneur, founder of simplecoding.dev | JOIN Medium, https://nilmadhab.medium.com/membership