Check perfect square using binary search
Company: LinkedIn
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates a candidate's competency in implementing binary search and handling integer arithmetic and overflow considerations when checking numeric properties. Commonly asked to assess algorithmic complexity analysis and practical coding ability within the Coding & Algorithms domain, it emphasizes practical application and O(log n) performance rather than purely conceptual reasoning.
Constraints
- Inputs are provided as Python literals matching the function signature.
- Return a deterministic exact-match result.
Examples
Input: (16,)
Expected Output: True
Explanation: Perfect square.
Input: (14,)
Expected Output: False
Explanation: Not a square.
Input: (1,)
Expected Output: True
Explanation: Smallest positive square.
Input: (2147395600,)
Expected Output: True
Explanation: Large square near 32-bit limit.
Hints
- Choose a representation that makes the core operation simple.
- Handle empty and boundary inputs before the main algorithm.