Solve the following coding tasks:
-
In a sorted array, every value appears exactly twice except for one value that appears once. Find the single value in O(log n) time and O(
-
extra space using a binary-search-based approach.
-
Given the root of an N-ary tree and a sequence of integers representing a path, determine whether this path exists in the tree. Each node may have multiple children and values are not guaranteed to be unique. A valid path must start from the root but does not need to end at a leaf node. Return true/false and analyze time and space complexity.
-
Given two integer arrays, compute the maximum length of a contiguous subarray that appears in both arrays. Discuss multiple approaches (e.g., dynamic programming; binary search on length with rolling hash) and their time/space trade-offs.