FastPrepFirst Letter to Appear Twice
Problems/First Letter to Appear Twice

First Letter to Appear Twice

Cisco logoCisco● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: In a Cisco interview for a second role, the first round had a few behavioral questions and then about four coding questions. One of the coding questions was about the first character in a string that shows up a second time.

The post gives no limits or examples. Here the string has 2 to 100 lowercase letters and always has a repeat. The word first means the letter whose second appearance comes earliest.

Our version is about 90% the same as the reported question.

You are given a string s of lowercase English letters. Return the first letter to appear twice.

Reading from left to right, this is the letter whose second appearance comes earliest. s always contains at least one letter that appears twice.

Function

repeatedCharacter(s: String) → char

Examples

Example 1

s = "abcbda"return = "b"

Reading left to right, b shows up again at index 3, before a shows up again at index 5. So the answer is b.

Example 2

s = "abba"return = "b"

a appears first, but its second appearance is at index 3. b appears again at index 2, which is earlier, so the answer is b.

Example 3

s = "zz"return = "z"

The second character repeats the first one.

Constraints

  • 2 <= s.length <= 100
  • s consists of lowercase English letters.
  • s has at least one repeated letter.

More Cisco interview questions

  • Check if a String Is a PalindromePHONE SCREEN · Seen Nov 2026
  • Find Unique ElementsPHONE SCREEN · Seen Nov 2026
  • Middle of a Linked ListPHONE SCREEN · Seen Nov 2026
  • Reverse a Linked ListPHONE SCREEN · Seen Nov 2026
  • Reverse a StringPHONE SCREEN · Seen Nov 2026
  • Valid ParenthesesPHONE SCREEN · Seen Nov 2026
  • K-Step Bit Flip with RetentionPHONE SCREEN · Seen Nov 2026
  • Longest Non-Repeating SubstringPHONE SCREEN · Seen Jul 2026
  • Todo Task Manager OperationsONSITE INTERVIEW · Seen Oct 2026
  • Find the Duplicate Number Without Modifying the ArrayONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
  • Halfway Course in a Single TrackCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Portfolio Valuation, Part 1Stripe · PHONE SCREENStripe interview questions
  • Single-Condition Product FilterCrowdstrike · PHONE SCREENCrowdstrike interview questions
  • Summarize Server Healthcheck LogsNVIDIA · PHONE SCREENNVIDIA interview questions
  • Known Words Matching Phone DigitsLinkedIn · PHONE SCREENLinkedIn interview questions
  • First Non-Repeated CharacterDell Technologies · PHONE SCREENDell Technologies interview questions
  • Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
  • First Non-Repeating CharacterGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
  • SimpleRDD Word CountDatologyAI · PHONE SCREEN
All Cisco interview questionsSee Cisco hiring insights
Saved
class Solution {
    public char repeatedCharacter(String s) {
        // Write your code here.
    }
}
Checking account…