
算法
文章平均质量分 67
旧事堪歌
这个作者很懒,什么都没留下…
展开
-
算法——排序
学习目标:1. 希尔排序2. 洗牌算法3. 葛立恒扫描法原创 2018-10-08 22:14:00 · 114 阅读 · 0 评论 -
leetcode 130.Surrounded Regions
leetcode 130.Surrounded Regions题目:Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounde...原创 2018-12-21 15:49:56 · 193 阅读 · 0 评论 -
leetcode 494. Target Sum
leetcode 494. Target Sum题目:You are given a list of non-negative integers, a1, a2, …, an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its ...原创 2018-12-16 14:45:36 · 149 阅读 · 0 评论 -
leetcode 134. Gas Station
leetcode 134. Gas Station题目:There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to ...原创 2018-12-10 15:09:29 · 270 阅读 · 0 评论 -
leetcode 113. Path Sum II
leetcode 113. Path Sum II题目: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.Example:Given the below b...原创 2018-12-15 19:54:53 · 137 阅读 · 0 评论 -
leetcode 105. Construct Binary Tree from Preorder and Inorder Traversal
leetcode 105. Construct Binary Tree from Preorder and Inorder Traversal题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist...原创 2018-12-14 15:53:26 · 148 阅读 · 0 评论 -
leetcode 365. Water and Jug Problem
leetcode 365. Water and Jug Problem题目:You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to me...原创 2018-12-20 11:29:45 · 204 阅读 · 0 评论 -
leetcode 55. Jump Game
leetcode 55. Jump Game题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that ...原创 2018-12-09 11:26:30 · 126 阅读 · 0 评论 -
leetcode 79.Word Search
leetcode 79.Word Search题目:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those h...原创 2018-12-06 18:02:04 · 186 阅读 · 0 评论 -
leetcode 300. Longest Increasing Subsequence
leetcode 300. Longest Increasing Subsequence题目:Given an unsorted array of integers, find the length of longest increasing subsequence.Example:Input: [10,9,2,5,3,7,101,18]Output: 4 Explanation: T...原创 2018-12-27 11:59:47 · 228 阅读 · 0 评论 -
leetcode 441. Arranging Coins
LeetCode 441. Arranging Coins题目:You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.Given n, find the total number of full stairca...原创 2018-12-17 13:27:51 · 123 阅读 · 0 评论 -
leetcode 343. Integer Break
leetcode 343. Integer Break题目:Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get....原创 2018-12-25 10:52:53 · 214 阅读 · 0 评论 -
leetcode 846. Hand of Straights
leetcode 846. Hand of Straights题目:Alice has a hand of cards, given as an array of integers.Now she wants to rearrange the cards into groups so that each group is size W, and consists of W consecuti...原创 2018-12-19 10:55:51 · 193 阅读 · 0 评论 -
leetcode 837. New 21 Game
leetcode 837. New 21 Game题目:Alice plays the following game, loosely based on the card game “21”.Alice starts with 0 points, and draws numbers while she has less than K points. During each draw, sh...原创 2018-12-24 12:12:22 · 231 阅读 · 0 评论 -
leetcode 179. Largest Number
leetcode 179. Largest Number题目:Given a list of non negative integers, arrange them such that they form the largest number.Example 1:Input: [10,2]Output: "210"Example 2:Input: [3,30,34,5,9]Out...原创 2018-12-18 17:56:48 · 217 阅读 · 0 评论 -
leetcode 606. Construct String from Binary Tree
leetcode 606. Construct String from Binary Tree题目:You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way.The null node needs to be r...原创 2018-12-12 11:00:43 · 257 阅读 · 0 评论 -
leetcode 881. Boats to Save People
leetcode 881. Boats to Save People题目:The i-th person has weight people[i], and each boat can carry a maximum weight of limit.Each boat carries at most 2 people at the same time, provided the sum of...原创 2018-12-23 16:07:52 · 215 阅读 · 0 评论 -
leetcode 98.Validate Binary Search Tree
leetcode 98.Validate Binary Search Tree题目:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nod...原创 2018-12-11 16:54:02 · 256 阅读 · 0 评论 -
leetcode 466. Count The Repetitions
leetcode 466. Count The Repetitions题目:Define S = [s,n] as the string S which consists of n connected strings s. For example, ["abc", 3] =“abcabcabc”.On the other hand, we define that string s1 can ...原创 2018-12-22 12:31:48 · 233 阅读 · 0 评论 -
leetcode 145.Binary Tree Postorder Traversal
leetcode 145. Binary Tree Postorder Traversal题目:Given a binary tree, return the postorder traversal of its nodes’ values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [3,2,1]...原创 2018-12-13 11:24:34 · 124 阅读 · 0 评论 -
leetcode 444. Sequence Reconstruction
leetcode 444. Sequence ReconstructionCheck whether the original sequence org can be uniquely reconstructed from the sequences in seqs. The org sequence is a permutation of the integers from 1 to n, w...原创 2018-12-07 17:29:59 · 815 阅读 · 0 评论 -
Leetcode 688.Knight Probability in Chessboard
Leetcode 688.Knight Probability in Chessboard题目:On an NxN chessboard, a knight starts at the r-th row and c-th column and attempts to make exactly K moves. The rows and columns are 0 indexed, so the...原创 2018-11-29 11:24:24 · 279 阅读 · 0 评论 -
Leetcode 135.Candy
Leetcode 135.Candy题目:There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child mus...原创 2018-11-26 11:56:56 · 303 阅读 · 0 评论 -
Leetcode 6. ZigZag Conversion
Leetcode 6. ZigZag Conversion题目:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legib...原创 2018-11-23 15:29:39 · 151 阅读 · 0 评论 -
Leetcode 600. Non-negative Integers without Consecutive Ones
Leetcode 600. Non-negative Integers without Consecutive Ones题目:Given a positive integer n, find the number of non-negative integers less than or equal to n, whose binary representations do NOT conta...原创 2018-11-25 17:14:46 · 304 阅读 · 0 评论 -
Leetcode 735. Asteroid Collision
Leetcode 735题目:We are given an array asteroids of integers representing asteroids in a row.For each asteroid, the absolute value represents its size, and the sign represents its direction (positive...原创 2018-11-24 12:10:11 · 161 阅读 · 0 评论 -
Leetcode 99. Recover Binary Search Tree
Leetcode 99. Recover Binary Search Tree题目: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-22 23:28:38 · 107 阅读 · 0 评论 -
Leetcode 90. Subsets II
Leetcode 90题目:Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.Example:Inp...原创 2018-11-21 18:41:01 · 157 阅读 · 0 评论 -
Leetcode 97. Interleaving String
Leetcode 97. Interleaving StringGiven s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.Example 1:Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"Out原创 2018-11-20 16:51:52 · 342 阅读 · 1 评论 -
leetcode 76.Minimum Window Substring
leetcode 76.Minimum Window Substring题目:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).Example:Input: S = "ADOBECODEBANC...原创 2018-12-02 10:52:19 · 239 阅读 · 1 评论 -
leetcode 690. Employee importance
leetcode 690. Employee importance题目:You are given a data structure of employee information, which includes the employee’s unique id, his importance valueand his direct subordinates’ id.For example,...原创 2018-12-02 12:09:31 · 162 阅读 · 0 评论 -
leetcode 109. Convert Sorted List to Binary Search Tree
leetcode 109. Convert Sorted List to Binary Search Tree题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-bal...原创 2018-12-05 11:22:01 · 156 阅读 · 0 评论 -
leetcode 738.Monotone Increasing Digits
leetcode 738.Monotone Increasing Digits题目: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 monoton...原创 2018-12-03 10:51:48 · 357 阅读 · 1 评论 -
leetcode 108. Convert Sorted Array to Binary Search Tree
leetcode 108. Convert Sorted Array to Binary Search Tree题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binar...原创 2018-12-05 11:16:17 · 343 阅读 · 0 评论 -
Leetcode 84.Largest Rectangle in Histogram
Leetcode 84.Largest Rectangle in Histogram题目:Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogr...原创 2018-11-28 13:04:25 · 139 阅读 · 0 评论 -
leetcode 93.Restore IP Addresses
leetcode 93.Restore IP Addresses题目:Given a string containing only digits, restore it by returning all possible valid IP address combinations.Example:Input: "25525511135"Output: ["255.255.11.135",...原创 2018-11-30 19:31:13 · 165 阅读 · 0 评论 -
Leetcode 250.Count Univalue Subtrees
Leetcode 250.Count Univalue Subtrees题目:Given a binary tree, count the number of uni-value subtrees.A Uni-value subtree means all nodes of the subtree have the same value.For example:Given binary ...原创 2018-11-27 16:29:18 · 227 阅读 · 0 评论 -
leetcode 553.Optimal Division
leetcode 553.Optimal Division题目:Given a list of positive integers, the adjacent integers will perform the float division. For example, [2,3,4] -> 2 / 3 / 4.However, you can add any number of par...原创 2018-11-30 12:42:19 · 158 阅读 · 0 评论 -
leetcode 91.Decode Ways
leetcode 91.Decode Ways题目:A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given a non-empty string containing...原创 2018-12-04 15:23:11 · 113 阅读 · 0 评论 -
leetcode 334. Increasing Triplet Subsequence
leetcode 334. Increasing Triplet Subsequence题目:Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.Formally the function should:Return true if ...原创 2018-12-26 11:01:37 · 249 阅读 · 0 评论