Compute unique-substring length and first unique index
Company: Boeing
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Technical Screen
Quick Answer: This question evaluates proficiency in string processing and character-frequency reasoning by combining tasks that measure longest distinct-character substring length and the index of the first non-repeating character.
Longest Substring Without Repeats
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ('abcabcbb',)
Expected Output: 3
Explanation: The longest distinct substring has length 3.
Input: ('bbbbb',)
Expected Output: 1
Explanation: Only one distinct character can be used.
Input: ('',)
Expected Output: 0
Explanation: Empty string has length 0.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.
First Unique Character Index
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ('leetcode',)
Expected Output: 0
Explanation: l is unique at index 0.
Input: ('loveleetcode',)
Expected Output: 2
Explanation: v is the first unique character.
Input: ('aabb',)
Expected Output: -1
Explanation: No unique character exists.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.