Asked inMeesho,SDE-2

Remove Consecutive Duplicates from String

Given a string STR consisting of both lower and upper case characters, your task is to remove consecutive duplicate characters and return the newly formed string.

Input:

'STR' as a string, containing no spaces.

Output:

The modified string with consecutive duplicates removed.

Example:

Input:
'aaaAAbbcccbd'
Output:
'aAbcbd'

Constraints:

  • 1 <= |STR| <= 105
  • Time limit: 1 second

Note:

No need to print anything; simply implement the function as described.

AnswerBot
1y

The task is to remove consecutive duplicate characters from a given string and return the new string.

  • Iterate through the characters of the string

  • Compare each character with the next character

  • If they a...read more

Help your peers!
Add answer anonymously...
Meesho SDE-2 Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter