Solve palindrome and missing-number variants
Company: Arista
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Technical Screen
Quick Answer: This question evaluates competencies in string processing, array manipulation, binary search, and algorithmic complexity analysis by asking a palindrome check and a missing-number problem that requires both O(n) and O(log n) reasoning, emphasizing edge-case handling and time/space complexity discussion.
Palindrome Check
Constraints
- Input is a string or None
Examples
Input: ('racecar',)
Expected Output: True
Explanation: Odd palindrome.
Input: ('',)
Expected Output: True
Explanation: Empty string.
Input: (None,)
Expected Output: False
Explanation: Null input.
Input: ('abca',)
Expected Output: False
Explanation: Mismatch.
Hints
- Compare characters from both ends.
Missing Number with Arbitrary Start
Constraints
- Exactly one number is missing from the represented consecutive sequence
Examples
Input: ([4, 5, 6, 8, 9],)
Expected Output: 7
Explanation: Missing in middle.
Input: ([10, 11, 13],)
Expected Output: 12
Explanation: Small example.
Input: ([1, 3],)
Expected Output: 2
Explanation: Missing second value.
Input: ([-3, -2, 0, 1],)
Expected Output: -1
Explanation: Negative start.
Hints
- For index i before the gap, nums[i] == nums[0] + i.