FastPrepLongest Substring Without Repeating Characters
Problems/Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

Oracle logoOracle● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: In the first coding round of an Oracle OCI loop for a senior platform engineer, one of the two questions was given only by name: find the longest stretch of a string in which no character appears twice. The name says subsequence, but a subsequence whose characters are all different is just a count of distinct characters, so this practice version uses the well-known contiguous substring task.

The post gives no examples or limits. Here the string has up to 5 * 10^4 printable ASCII characters, and an empty string returns 0.

The judged task matches the post at about 80%.

Given a string s, return the length of the longest substring of s in which no character appears more than once.

A substring is a run of characters that are next to each other in s. Uppercase and lowercase letters are different characters, and a space is a character too. If s is empty, return 0.

Function

lengthOfLongestSubstring(s: String) → int

Examples

Example 1

s = "pqrpqrqq"return = 3

The substring "pqr" has three different characters. Any substring of length 4 repeats a character; for example "pqrp" has p twice. So the answer is 3.

Example 2

s = "aaaa"return = 1

Every substring longer than one character repeats a, so the answer is 1.

Example 3

s = "dvdf"return = 3

The substring "vdf" has three different characters, and the whole string repeats d, so the answer is 3. Note that the best substring starts at the v, not at the second d.

Constraints

  • 0 <= s.length <= 5 * 10^4
  • s consists of English letters, digits, symbols and spaces (printable ASCII characters).

More Oracle Onsite Interview questions

  • Minimum Meeting RoomsONSITE INTERVIEW · Seen Nov 2026
  • Shortest Window with Required CountsONSITE INTERVIEW · Seen Nov 2026
  • Maximum Subarray Sum with One DeletionONSITE INTERVIEW · Seen Nov 2026
  • Shortest Deletion for Distinct CharactersONSITE INTERVIEW · Seen Nov 2026
  • Count Dropped Rate-Limited RequestsONSITE INTERVIEW · Seen Nov 2026
  • Design Authentication ManagerONSITE INTERVIEW · Seen Oct 2026
  • Maximum Bouquet ValueONSITE INTERVIEW · Seen Oct 2026
  • Cache an Expensive Service Across ThreadsONSITE INTERVIEW · Seen Oct 2026
  • Island Count and Maximum AreaONSITE INTERVIEW · Seen Oct 2026
  • Largest Island After One FlipONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Longest Substring Without Repeating CharactersSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Longest Substring Without Repeating CharactersMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Longest Substring Without Repeating CharactersGoogle · ONSITE INTERVIEWGoogle interview questions
  • Longest Substring Without Repeating CharactersAmazon · ONSITE INTERVIEW
  • Longest Substring Without Repeating CharactersInfosys · ONSITE INTERVIEWInfosys interview questions
  • Longest Substring Without Repeating CharactersOmnissa · ONSITE INTERVIEWOmnissa interview questions
  • Longest Substring Without Repeating CharactersBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Longest Substring with At Most K Distinct CharactersGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Sliding-Window Rate LimiterStripe · PHONE SCREEN · ONSITE INTERVIEWStripe interview questions
  • Longest Substring Without Repeated CharactersDatadog · ONSITE INTERVIEWDatadog interview questions

Oracle interview experiences

  • Oracle SWE Onsite Interview Experience: 1 Experience
All Oracle interview questionsSee Oracle hiring insights
Saved
class Solution {
    public int lengthOfLongestSubstring(String s) {
        // Write your code here.
    }
}
Checking account…