随笔分类 - Recursive
发表于 2019-04-26 21:22阅读:393评论:0推荐:0
摘要:Special binary strings are binary strings with the following two properties: The number of 0's is equal to the number of 1's. Every prefix of the bina
阅读全文 »
发表于 2019-02-15 20:05阅读:206评论:0推荐:0
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo
阅读全文 »
发表于 2019-02-05 00:31阅读:215评论:0推荐:0
摘要:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is
阅读全文 »
发表于 2019-01-09 21:05阅读:232评论:0推荐:0
摘要:Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits. (Recall that an integer has m
阅读全文 »
发表于 2018-12-20 18:20阅读:225评论:0推荐:0
摘要:Given an m x n matrix of positive integers representing the height of each unit cell in a 2D elevation map, compute the volume of water it is able to
阅读全文 »
发表于 2018-12-10 18:00阅读:205评论:0推荐:0
摘要:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Example
阅读全文 »
发表于 2018-12-10 17:15阅读:195评论:0推荐:0
摘要:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 whic
阅读全文 »
发表于 2018-12-10 12:05阅读:191评论:0推荐:0
摘要:Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any
阅读全文 »
发表于 2018-12-09 21:13阅读:202评论:0推荐:0
摘要:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note: A leaf is a node with no children. Exampl
阅读全文 »
发表于 2018-12-09 18:53阅读:182评论:0推荐:0
摘要:Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l
阅读全文 »
发表于 2018-12-09 18:14阅读:215评论:0推荐:0
摘要:Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Example 1: Input: [1,3,null,null,2
阅读全文 »
发表于 2018-11-23 15:50阅读:173评论:0推荐:0
摘要:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes
阅读全文 »
发表于 2018-11-06 20:28阅读:177评论:0推荐:0
摘要:Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algor
阅读全文 »
发表于 2018-10-28 16:49阅读:297评论:0推荐:0
摘要:Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not conta
阅读全文 »
发表于 2018-10-26 21:24阅读:189评论:0推荐:0
摘要:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representati
阅读全文 »
发表于 2018-10-24 12:02阅读:168评论:0推荐:0
摘要:Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. Exampl
阅读全文 »
发表于 2018-10-24 11:03阅读:277评论:0推荐:0
摘要:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: AC code: Runtime: 88 ms, faster than 42.24% of C++
阅读全文 »
发表于 2018-10-18 22:16阅读:173评论:0推荐:0
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return the
阅读全文 »
发表于 2018-10-18 22:11阅读:150评论:0推荐:0
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all
阅读全文 »
发表于 2018-10-17 22:00阅读:224评论:0推荐:0
摘要:Implement pow(x, n), which calculates x raised to the power n (xn). Example 1: Example 2: Example 3: Note: -100.0 < x < 100.0 n is a 32-bit signed int
阅读全文 »