Amazon Online Assessment Questions
847

|| EASY ||

  • CHECK BST: Write a function to check if a binary tree is a binary search tree

  • SMALLEST COMMMON SUBTREE: Given the root node and the values of any two nodes in a binary search tree, return the smallest subtree that contains the two nodes as a TreeNode.

  • BINARY SEARCH TREE SUM: Given a binary search tree, compute the sum of all the nodes in the tree.

  • MAX TRIPLETS: If I give you an array of n integers, find the largest three numbers that will result in the largest product(try to optimize!)

  • TWO SUM: Given two lists of integers, of length m and n respectively, return true if there are two numbers that sum up to a target(try to optimize!)

|| MEDIUM ||

  • NUMBER GAME: Alice and Bob take turns choosing numbers - either the first or last element in an unsorted array - and all numbers are exhausted. The winner will be the one who has a large cumulative total sum of picked numbers. Return an array of indexes that contain Alice's picks of numbers in the array, if Alice can win. If Alice cannot win, return -1.

  • COURSE SCHEDULE: You are given a list of pairs. Each pair contains two things. pair[0] is equal to a course. pair[1] is equal to a prerequisite. So for you to take course pair[0], you had to have taken pair[1] first. If you can sucessfully complete the courses, return True. If you cannot(say you need to take a course 0 to take course 1, but you also need to take course 1 to take course 0), return False. FOLLOW UP: return the order in which you have to take the courses. If you cannot take the courses, return []

  • FIND MAX IN INCREASING DECREASING ARRAY: Given an array arr arranged in a way where up to some point arr is strictly increaasing, and further on after that point arr is strictly decreasing, find the max value in arr. The overall time complexity should be less than O(n).

  • LEFT VIEW OF BINARY TREE: Given the root of a binary tree, return the leftmost value on each level of the tree.

    • EXAMPLE:
    • TREE = {val: 0, left : {val: 5}, right: {val: 2, right: {val: 1}}}}
    • RETURNS: [0, 5, 1]
  • GAME OF LIFE: You are given a two dimensional matrix where a 1 represents a live cell and a 0 represents a dead cell. A cell's(living or dead) neighbors are in it's immediate horizontal, vertical, and diagonal cells. Compute the next state of the matrix according to Conway's game of life:

    • Any living cell with 2 or 3 live neighbors lives.
    • Any dead cell with 3 living neighbors becomes a live cell.
    • All other cells die

|| HARD ||

  • INTERGER TO ENGLISH: Given a non-negative integer num, convert it to an English number word as a string. num is guaranteed to be less than one trillion.
    • INPUT: num = 823418
    • OUTPUT: 'Eight Hundred Twenty Three Thousand Four Hundred Eighteen'

Solutions will come out in a few days. If this post helped you, please upvote. Thanks for reading!
NOTICE: || Problems 1, 3, 4, 6, 7, 9, and 10 can be found in LeetCode! ||

Comments (1)