Implement exponentiation and link tree neighbors
Company: Meta
Role: Machine Learning Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Technical Screen
Quick Answer: This question evaluates numerical algorithm implementation and in-place tree traversal skills, specifically fast exponentiation with careful edge-case and precision handling and iterative linking of next pointers in a perfect binary tree.
Fast Exponentiation
Examples
Input: (2.0, 10)
Expected Output: 1024.0
Explanation: Positive exponent.
Input: (2.0, -2)
Expected Output: 0.25
Explanation: Negative exponent.
Input: (1.5, 0)
Expected Output: 1.0
Explanation: Zero exponent.
Input: (-2.0, 3)
Expected Output: -8.0
Explanation: Negative base.
Link Neighbors in a Perfect Binary Tree
Examples
Input: ([1, 2, 3, 4, 5, 6, 7],)
Expected Output: [None, 3, None, 5, 6, 7, None]
Explanation: Three levels.
Input: ([1],)
Expected Output: [None]
Explanation: Single root.
Input: ([],)
Expected Output: []
Explanation: Empty tree.