Delete Node in a BST Problem

  1. Search for a node to remove.
  2. If the node is…


Photo by Andrew H on Unsplash

Largest Component Size by Common Factor Problem

  • There are A.length nodes, labelled A[0] to A[A.length - 1];
  • There is an edge between A[i] and A[j] if and only if A[i] and A[j] share a common factor greater than 1.
Input: [4,6,15,35]
Output: 4

Photo by Andrew H on Unsplash

Pancake Sorting Problem

  • Choose an integer k where 0 <= k < A.length.
  • Reverse the sub-array A[0...k].


Photo by Andrew H on Unsplash

Implement Rand10() Using Rand7() Problem

Input: 1
Output: [7]
Input: 2
Output: [8,4]
Input: 3
Output: [8,1,10]
  1. rand7 is predefined.
  2. Each testcase has one argument: n, the number of times that rand10 is called.
  1. What is the expected value for the number of calls to rand7() function?
  2. Could you minimize the number of calls to rand7()?

Solution


Photo by Andrew H on Unsplash

Find Right Interval Problem


Photo by Andrew H on Unsplash

Fizz Buzz Problem

n = 15,Return:
[
"1",
"2",
"Fizz",
"4",
"Buzz",
"Fizz",
"7",
"8",
"Fizz",
"Buzz",
"11",
"Fizz",
"13",
"14",
"FizzBuzz"
]

Solution


Photo by Andrew H on Unsplash

Minimum Cost For Tickets Problem

  • a…

Photo by Andrew H on Unsplash

Sum of Left Leaves Problem

3
/ \
9 20
/ \
15 7
There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.

Solution


Photo by Andrew H on Unsplash

Stream of Characters Problem

  • StreamChecker(words): Constructor, init the data structure with the given words.
  • query(letter): returns true if and only if for some k >= 1, the last k characters queried (in order from oldest to newest, including this letter just queried) spell one of the words in…

Photo by Andrew H on Unsplash

Random Point in Non-overlapping Rectangles Problem

  1. An integer point is a point that has integer coordinates.
  2. A point on the perimeter of a rectangle is included in the…

Quico Llinares Llorens

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store