随笔分类 -  Recursion

摘要:In LeetCode Store, there are n items to sell. Each item has a price. However, there are some special offers, and a special offer consists of one or mo 阅读全文
posted @ 2025-05-04 07:39 北叶青藤 阅读(4) 评论(0) 推荐(0)
摘要:Given a robot cleaner in a room modeled as a grid. Each cell in the grid can be empty or blocked. The robot cleaner with 4 given APIs can move forward 阅读全文
posted @ 2021-03-29 04:32 北叶青藤 阅读(69) 评论(0) 推荐(0)
摘要:给一个phone pad mapping like: {1,{‘A’,'B' , 'C'}}, {2, { 'D' , 'E' , 'F' }} ... {0, {'X', 'Y', 'Z'}}. 按一次1 返回A,连续两次返回B, 连续四次重新返回A. 输入一组数字,不清楚之间间隔,返回所有可能的 阅读全文
posted @ 2021-03-05 00:56 北叶青藤 阅读(89) 评论(0) 推荐(0)
摘要:Your task is to design the basic function of Excel and implement the function of sum formula. Specifically, you need to implement the following functi 阅读全文
posted @ 2019-08-12 09:14 北叶青藤 阅读(337) 评论(0) 推荐(0)
摘要:You are given a string expression representing a Lisp-like expression to return the integer value of. The syntax for these expressions is given as fol 阅读全文
posted @ 2019-07-20 13:08 北叶青藤 阅读(356) 评论(0) 推荐(0)
摘要:An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). Given a coordinate (sr, 阅读全文
posted @ 2019-07-03 03:23 北叶青藤 阅读(192) 评论(0) 推荐(0)
摘要:In this problem, a tree is an undirected graph that is connected and has no cycles. The given input is a graph that started as a tree with N nodes (wi 阅读全文
posted @ 2019-06-22 10:46 北叶青藤 阅读(216) 评论(0) 推荐(0)
摘要:Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwe 阅读全文
posted @ 2019-05-20 01:39 北叶青藤 阅读(241) 评论(0) 推荐(0)
摘要:Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into k non-empty subsets whose sums are all 阅读全文
posted @ 2019-05-06 00:31 北叶青藤 阅读(414) 评论(0) 推荐(0)
摘要:Given an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is be 阅读全文
posted @ 2019-04-22 01:48 北叶青藤 阅读(394) 评论(0) 推荐(0)
摘要:You have 4 cards each containing a number from 1 to 9. You need to judge whether they could operated through *, /, +, -, (, ) to get the value of 24. 阅读全文
posted @ 2019-04-22 01:04 北叶青藤 阅读(175) 评论(0) 推荐(0)
摘要:Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) Yo 阅读全文
posted @ 2019-02-03 07:59 北叶青藤 阅读(185) 评论(0) 推荐(0)
摘要:In the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach o 阅读全文
posted @ 2017-01-02 02:26 北叶青藤 阅读(349) 评论(0) 推荐(0)
摘要:Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or *between the di 阅读全文
posted @ 2016-10-23 23:07 北叶青藤 阅读(235) 评论(0) 推荐(0)
摘要:Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of th 阅读全文
posted @ 2016-08-07 05:21 北叶青藤 阅读(283) 评论(0) 推荐(0)
摘要:Print numbers from 1 to the largest number with N digits by recursion. Notice It's pretty easy to do recursion like: recursion(i) { if i > largest num 阅读全文
posted @ 2016-07-16 01:37 北叶青藤 阅读(240) 评论(0) 推荐(0)
摘要:Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. Given a st 阅读全文
posted @ 2016-07-09 09:23 北叶青藤 阅读(200) 评论(0) 推荐(0)
摘要:There is a fence with n posts, each post can be painted with one of the k colors.You have to paint all the posts such that no more than two adjacent f 阅读全文
posted @ 2016-07-09 06:41 北叶青藤 阅读(295) 评论(0) 推荐(0)
摘要:Segment Tree Build I The structure of Segment Tree is a binary tree which each node has two attributes start and end denote an segment / interval. sta 阅读全文
posted @ 2016-07-09 00:15 北叶青藤 阅读(153) 评论(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 阅读全文
posted @ 2016-07-08 11:30 北叶青藤 阅读(152) 评论(0) 推荐(0)