Skip to main content
968, Binary Tree Cameras

I Problem

You are given the root of a binary tree. We install cameras on the tree nodes where each camera at a node can monitor its parent, itself, and its immediate children.

Return the minimum number of cameras needed to monitor all nodes of the tree.


MikeAbout 3 mingreedyhardbinary treedepth first searchdynamic programming
135, Candy

I Problem

There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings.

You are giving candies to these children subjected to the following requirements:

  • Each child must have at least one candy.
  • Children with a higher rating get more candies than their neighbors.

MikeAbout 2 mingreedyhardarraygreedy
37, Sudoku Solver

I Problem

Write a program to solve a Sudoku puzzle by filling the empty cells.

A sudoku solution must satisfy all of the following rules:

  1. Each of the digits 1-9 must occur exactly once in each row.
  2. Each of the digits 1-9 must occur exactly once in each column.
  3. Each of the digits 1-9 must occur exactly once in each of the 9 3x3 sub-boxes of the grid.

MikeAbout 4 minbacktrackinghardarrayhash tablematrixbacktracking
52, N-Queens II

I Problem

The n-queens puzzle is the problem of placing nqueens on an n x n chessboard such that no two queens attack each other.

Given an integer n, return the number of distinct solutions to the n-queens puzzle.


MikeAbout 1 minbacktrackinghardbacktracking
51, N-Queens

I Problem

The n-queens puzzle is the problem of placing nqueens on an n x n chessboard such that no two queens attack each other.

Given an integer n, return all distinct solutions to the n-queens puzzle. You may return the answer in any order.


MikeAbout 1 minbacktrackinghardarraybacktracking
239, Sliding Window Maximum

I Problem

You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position.


MikeAbout 3 minstack/queuehardarrayqueuesliding windowheadmonotonic queue
76, Minimum Window Substring

I Problem

Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is included in the window. If there is no such substring, return the empty string "".

The testcases will be generated such that the answer is unique.


MikeAbout 2 minarrayhardhash tablestringsliding window