Find First Repeated Character in a String

Given a string 'STR' composed of lowercase English letters, identify the character that repeats first in terms of its initial occurrence.

Example:

Input:
STR = "abccba"
Output:
"a"
Explanation:

Although the first repeating character is 'c', the character 'a' is the first repeated character by initial appearance.

Constraints:

  • 1 <= T <= 200
  • 0 <= length of S <= 10000
  • ‘S’ consists of lowercase English alphabets.

In the scenario where no repeated character exists, output '%'.

Note:

Ensure that you return the repeated character that appears first, rather than simply the first character that repeats. If there are no repeating characters, return '%'. The function to implement is called “repeatedCharacter”.

AnswerBot
4mo

The task is to find the first repeated character in a given string of lowercase English letters.

  • Iterate through the string and keep track of characters seen so far in a set.

  • If a character is already i...read more

Help your peers!
Select
Add answer anonymously...

Delhivery Associate Software Engineer interview questions & answers

An Associate Software Engineer was asked Q. Infix to Postfix Conversion You are provided with a string EXP which represents ...read more
An Associate Software Engineer was asked Q. Maximum Sum Path in a Binary Tree Problem Statement You are provided with a bina...read more
An Associate Software Engineer was asked Q. Find First Repeated Character in a String Given a string 'STR' composed of lower...read more

Popular interview questions of Associate Software Engineer

An Associate Software Engineer was asked Q1. Infix to Postfix Conversion You are provided with a string EXP which represents ...read more
An Associate Software Engineer was asked Q2. Maximum Sum Path in a Binary Tree Problem Statement You are provided with a bina...read more
An Associate Software Engineer was asked Q3. Find First Repeated Character in a String Given a string 'STR' composed of lower...read more
Delhivery Associate Software Engineer 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