Skip to main content
62, Unique Paths

I Problem

There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time.


MikeAbout 2 mindynamic programmingmediummathdynamic programmingcombinatorics
343, Integer Break

I Problem

Given an integer n, break it into the sum of k positive integers, where k >= 2, and maximize the product of those integers.

Return the maximum product you can get.

Example 1
Input: n = 2
Output: 1
Explanation: 2 = 1 + 1, 1 × 1 = 1.


MikeAbout 2 mindynamic programmingmediummathdynamic programming
1137, N-th Tribonacci Number

I Problem

The Tribonacci sequence Tn is defined as follows:

T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0.

Given n, return the value of Tn.

Example 1
Input: n = 4
Output: 4
Explanation:
T_3 = 0 + 1 + 1 = 2
T_4 = 1 + 1 + 2 = 4


MikeAbout 3 mindynamic programmingeasymathdynamic programmingmemoization
70, Climbing Stairs

I Problem

You are climbing a staircase. It takes n steps to reach the top.

Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

Example 1
Input: n = 2
Output: 2
Explanation: There are two ways to climb to the top.


MikeAbout 3 mindynamic programmingeasymathdynamic programmingmemoization
509, Fibonacci Number

I Problem

The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,

  • F(0) = 0, F(1) = 1
  • F(n) = F(n - 1) + F(n - 2), for n > 1

MikeAbout 3 mindynamic programmingeasyrecursionmemoizationmathdynamic programming
738, Monotone Increasing Digits

I Problem

An integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y.

Given an integer n, return the largest number that is less than or equal to n with monotone increasing digits.


MikeAbout 1 mingreedymediumgreedymath
202, Happy Number

I Problem

Write an algorithm to determine if a number n is happy.

A happy number is a number defined by the following process:

  • Starting with any positive integer, replace the number by the sum of the squares of its digits.
  • Repeat the process until the number equals 1(where it will stay), or it loops endlessly in a cycle which does not include 1.
  • Those numbers for which this process ends in 1 are happy.

MikeAbout 1 minhashtableeasyhash tablemathtwo pointers
367, Valid Perfect Square

I Problem

Given a positive integer num, return true if num is a perfect square or false otherwise.

A perfect square is an integer that is the square of an integer. In other words, it is the product of some integer with itself.

You must not use any built-in library function, such as sqrt.


MikeAbout 1 minarrayeasymathbinary search
69, Sqrt(x)

I Problem

Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well.

You must not use any built-in exponent function or operator.

For example, do not use pow(x, 0.5) in c++ or x ** 0.5 in python.


MikeAbout 2 minarrayeasymathbinary search