V Daily Coding Problems
July 19, 2021 ยท View on GitHub
V solutions to problems sent by dailycodingproblem.com
Problem 1
This problem was asked by Apple.
Implement the function fib(n), which returns the nth number in the Fibonacci sequence, using only O(1) space.
Problem 2
This problem was asked by Facebook.
Given an array of numbers of length N, find both the minimum and maximum using less than 2 * (N - 2) comparisons.
Problem 3
This problem was asked by Nvidia.
You are given a list of N points (x1, y1), (x2, y2), ..., (xN, yN) representing a polygon. You can assume these points are given in order; that is, you can construct the polygon by connecting point 1 to point 2, point 2 to point 3, and so on, finally looping around to connect point N to point 1.
Determine if a new point p lies inside this polygon. (If p is on the boundary of the polygon, you should return False).
Problem 4
This problem was asked by Amazon.
A tree is symmetric if its data and shape remain unchanged when it is reflected about the root node. The following tree is an example: Given a k-ary tree, determine whether it is symmetric.