Skip to main content
746, Min Cost Climbing Stairs

I Problem

You are given an integer array cost where cost[i] is the cost of iᵗʰ step on a staircase. Once you pay the cost, you can either climb one or two steps.

You can either start from the step with index 0, or the step with index 1.


MikeAbout 2 mindynamic programmingeasyarraydynamic 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
860, Lemonade Change

I Problem

At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You must provide the correct change to each customer so that the net transaction is that the customer pays $5.


MikeAbout 2 mingreedyeasygreedyarray
1005, Maximize Sum Of Array After K Negations

I Problem

Given an integer array nums and an integer k, modify the array in the following way:

  • choose an index i and replace nums[i] with -nums[i].

You should apply this process exactly k times. You may choose the same index i multiple times.


MikeAbout 2 mingreedyeasygreedyarraysorting
455, Assign Cookies

I Problem

Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie.

Each child i has a greed factor g[i], which is the minimum size of a cookie that the child will be content with; and each cookie j has a size s[j]. If s[j] >= g[i], we can assign the cookie j to the child i, and the child i will be content. Your goal is to maximize the number of your content children and output the maximum number.


MikeAbout 2 mingreedyeasygreedyarraytwo pointerssorting
559, Maximum Depth of N-ary Tree

I Problem

Given a n-ary tree, find its maximum depth.

The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples).


MikeAbout 3 minbinary treeeasytreedepth first searchbreadth first search
572, Subtree of Another Tree

I Problem

Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise.

A subtree of a binary tree tree is a tree that consists of a node in tree and all of this node's descendants. The tree tree could also be considered as a subtree of itself.


MikeAbout 3 minbinary treeeasybinary treedepth first searchstring matchinghash function
100, Same Tree

I Problem

Given the roots of two binary trees p and q, write a function to check if they are the same or not.

Two binary trees are considered the same if they are structurally identical, and the nodes have the same value.

Example 1

Input: p = [1, 2, 3], q = [1, 2, 3]
Output: true


MikeAbout 2 minbinary treeeasybinary treedepth first searchbreadth first search
2
3
4
5
6