Solve sliding window and tree BFS problems
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Technical Screen
1) Sliding window: Given an array of positive integers nums and an integer target, return the minimal length of a contiguous subarray whose sum is at least target; return 0 if no such subarray exists. Aim for O(n) time and O(
1) extra space using a sliding window.
2) Tree BFS: Given the root of a binary tree, return a list of lists of node values representing the tree’s level-order traversal from left to right (nodes within each level listed left to right). Provide an iterative BFS implementation and analyze time and space complexity.
Quick Answer: This question evaluates algorithmic problem-solving and data-structure manipulation, focusing on the sliding window technique for array subproblems and iterative breadth-first search for binary tree level-order traversal, with emphasis on time and space complexity reasoning.