随笔分类 -  leetcode

摘要:Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. 阅读全文
posted @ 2020-03-22 18:44 米开朗菠萝 阅读(120) 评论(0) 推荐(0)
摘要:A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The 阅读全文
posted @ 2020-03-22 17:53 米开朗菠萝 阅读(156) 评论(0) 推荐(0)
摘要:Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Example: Input: 2 Output: 91 Explanation: The answer shoul 阅读全文
posted @ 2020-03-22 11:16 米开朗菠萝 阅读(119) 评论(0) 推荐(0)
摘要:Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2 阅读全文
posted @ 2020-03-21 22:19 米开朗菠萝 阅读(149) 评论(0) 推荐(0)
摘要:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Example 1: Input: n = 12 O 阅读全文
posted @ 2020-03-21 21:34 米开朗菠萝 阅读(114) 评论(0) 推荐(0)
摘要:You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you nee 阅读全文
posted @ 2020-03-21 21:07 米开朗菠萝 阅读(154) 评论(0) 推荐(0)
摘要:Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Example: Input: n = 10 Outpu 阅读全文
posted @ 2020-03-21 19:35 米开朗菠萝 阅读(115) 评论(0) 推荐(0)
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example: Input: 1 0 1 0 0 1 0 1 1 1 阅读全文
posted @ 2020-03-21 18:46 米开朗菠萝 阅读(130) 评论(0) 推荐(0)
摘要:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Example 1: Input: 阅读全文
posted @ 2020-03-19 21:36 米开朗菠萝 阅读(100) 评论(0) 推荐(0)
摘要:On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. Y 阅读全文
posted @ 2020-03-18 11:53 米开朗菠萝 阅读(121) 评论(0) 推荐(0)
摘要:Given a string s and a string t, check if s is subsequence of t. You may assume that there is only lower case English letters in both s and t. t is po 阅读全文
posted @ 2020-03-18 10:41 米开朗菠萝 阅读(138) 评论(0) 推荐(0)
摘要:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Given nums = [-2, 0, 3, -5, 2, -1] sumR 阅读全文
posted @ 2020-03-17 15:37 米开朗菠萝 阅读(83) 评论(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 阅读全文
posted @ 2020-03-16 22:36 米开朗菠萝 阅读(118) 评论(0) 推荐(0)
摘要:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequ 阅读全文
posted @ 2020-03-16 20:47 米开朗菠萝 阅读(157) 评论(0) 推荐(0)
摘要:Given a binary tree, return all root-to-leaf paths. Note: A leaf is a node with no children. Example: Input: 1 / \ 2 3 \ 5 Output: ["1->2->5", "1->3"] 阅读全文
posted @ 2020-03-12 05:11 米开朗菠萝 阅读(96) 评论(0) 推荐(0)
摘要:Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note:You may assume k is always valid, 1 ≤ k ≤ BST's 阅读全文
posted @ 2020-03-12 04:48 米开朗菠萝 阅读(83) 评论(0) 推荐(0)
摘要:Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? Example: Input: 3 Output: 5 Explanation: Given n = 3, the 阅读全文
posted @ 2020-03-11 11:01 米开朗菠萝 阅读(114) 评论(0) 推荐(0)
摘要:You need to find the largest value in each row of a binary tree. Example: Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9] # Definition for a binary tre 阅读全文
posted @ 2020-03-10 20:22 米开朗菠萝 阅读(134) 评论(0) 推荐(0)
摘要:Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input: 2 / \ 1 3 Output: 1 Example 2: Input: 1 / \ 2 3 / / \ 4 5 阅读全文
posted @ 2020-03-10 20:10 米开朗菠萝 阅读(120) 评论(0) 推荐(0)
摘要:Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 1 阅读全文
posted @ 2020-03-10 19:41 米开朗菠萝 阅读(140) 评论(0) 推荐(0)