256. Paint House

Problem description:

There is a row of n houses, where each house can be painted one of three colors: red, blue, or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.

Readmore

50. Pow(x, n)

Problem description:

Implement pow(x, n), which calculates x raised to the power n (i.e., xn).

Readmore

605. Can Place Flowers

Problem description:

You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots.

Readmore

742. Closest Leaf in a Binary Tree

Problem description:

Given the root of a binary tree where every node has a unique value and a target integer k, return the value of the nearest leaf node to the target k in the tree.

Readmore

32. Longest Valid Parentheses

Problem description:

Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.

Readmore

315. Count of Smaller Numbers After Self

Problem description:

You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].

Readmore

576. Out of Boundary Paths

Problem description:

There is an m x n grid with a ball. The ball is initially at the position [startRow, startColumn]. You are allowed to move the ball to one of the four adjacent cells in the grid (possibly out of the grid crossing the grid boundary). You can apply at most maxMove moves to the ball.

Readmore

392. Is Subsequence

Problem description:

Solution:

time complexity: $O()$
space complexity: $O()$
reference:
related problem:

Readmore

792. Number of Matching Subsequences

Problem description:

Given a string s and an array of strings words, return the number of words[i] that is a subsequence of s.

Readmore

140. Word Break II

Problem description:

Given a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences in any order.

Readmore