Remove Duplicates from Sorted Array Problem Statement

You are given a sorted integer array ARR of size N. Your task is to remove the duplicates in such a way that each element appears only once. The output should be the length of the array after removal of duplicates.

Example:

Input:
T = 1, N = 5, ARR = [1, 1, 2, 2, 3]
Output:
3
Explanation:

The array after removing duplicates becomes [1, 2, 3], thus the length is 3.

Constraints:

  • 1 <= T <= 5
  • 1 <= N <= 105
  • -109 <= ARR[i] <= 109
  • Time limit: 1 sec

Note:

 - Do not allocate extra space for another array. Perform the operation in-place with O(1) extra memory. 
AnswerBot
1y

The task is to remove duplicates from a sorted integer array in-place and return the length of the modified array.

  • Use two pointers, one for iterating through the array and another for keeping track of...read more

Help your peers!
Select
Add answer anonymously...

Newgen Software Technologies Software Developer interview questions & answers

A Software Developer was asked 12mo agoQ. What are constructors?
A Software Developer was asked 12mo agoQ. Define the concept of OOPs.
A Software Developer was asked Q. What is OOPS in Java?

Popular interview questions of Software Developer

A Software Developer was asked 12mo agoQ1. What are constructors?
A Software Developer was asked 12mo agoQ2. Define the concept of OOPs.
A Software Developer was asked Q3. What is OOPS in Java?
Newgen Software Technologies Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits