自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(51)
  • 收藏
  • 关注

原创 Leetcode 127: Word Ladder

Question:Given two words (beginWord and endWord), and a dictionary’s word list, find the length of shortest transformation sequence from beginWord to endWord, such that:Only one letter can be chang...

2019-07-02 12:52:03 119

原创 Leetcode 103: Binary Tree Zigzag Level Order Traversal

Question:Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given b...

2019-06-30 01:56:53 103

原创 Binary Tree & Binary Search Tree

Binary TreeDefinition: at most two children node.Binary Tree Example:class TreeNode { int value; TreeNode* left; TreeNode* right;}基本知识点Tree TraversePre-order先打印自己的节点,然后打印左节点(recurse后变成当前节...

2019-06-29 01:17:23 443

原创 369. Plus One Linked List

QuestionGiven a non-negative integer represented as non-empty a singly linked list of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 ...

2019-06-27 02:40:41 111

原创 LeetCode: 82&83: Remove Duplicates from Sorted List II&I

QuestionGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.Example 1:Input: 1->2->3->3->4->4->5Output...

2019-06-25 05:20:12 77

原创 Leetcode: 61. Rotate List

Question:Given a linked list, rotate the list to the right by k places, where k is non-negative.Example 1:Input: 1->2->3->4->5->NULL, k = 2Output: 4->5->1->2->3->NUL...

2019-06-23 14:32:04 93

原创 Leetcode: 341. Flatten Nested List Iterator

Question:Given a nested list of integers, implement an iterator to flatten it.Each element is either an integer, or a list – whose elements may also be integers or other lists.Example 1:Input: [[...

2019-06-22 07:42:17 91

原创 Leetcode: 42. Trapping Rain Water

Question:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.The above elevation map is represented...

2019-06-22 06:52:56 97

原创 Leetcode: 240. Search a 2D Matrix II

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers in each ...

2019-06-17 10:51:16 62

原创 Leetcode: 695. Max Area of Island && Leetcode 200: Num of Islands

Question:Given a non-empty 2D array gridof 0’s and 1’s, an island is a group of 1’s (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid a...

2019-06-14 13:30:37 92

原创 Leetcode: 621. Task Scheduler

Question:Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks could be done without original order. Each t...

2019-06-14 10:14:42 145

原创 Leetcode: 448. Find All Numbers Disappeared in an Array

Question:Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this arr...

2019-06-13 09:01:40 85

原创 Leetcode: 289. Game of Life

Question:Given a board with m by n cells, each cell has an initial state live (1) or dead (0). Each cell interacts with its eight neighbors (horizontal, vertical, diagonal) using the following four r...

2019-06-11 03:45:28 83

原创 Leetcode: 152. Maximum Product Subarray

Question:Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.Example 1:Input: [2,3,-2,4]Output: 6Explanation:...

2019-06-09 02:18:40 105

原创 Leetcode: 121. Best Time to Buy and Sell Stock && 122. Best Time to Buy and Sell Stock II

121Question:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share o...

2019-06-08 08:18:03 116

原创 Leetcode: 238. Product of Array Except Self

QuestionGiven an array numsof n integers where n > 1, return an array output such that output[i]is equal to the product of all the elements of numsexcept nums[i].Example:Input: [1,2,3,4]Outp...

2019-06-08 02:01:32 76

原创 Leetcode: 56. Merge Intervals

Question:Given a collection of intervals, merge all overlapping intervals.Example:Input: [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]Explanation: Since intervals [1,3] and [2,6] ov...

2019-06-05 02:32:03 89

原创 Leetcode: 973. K Closest Points to Origin (customized comparator)

Question:We have a list of pointson the plane. Find the Kclosest points to the origin (0, 0).(Here, the distance between two points on a plane is the Euclidean distance.)You may return the answer ...

2019-06-05 01:37:10 122

原创 Leetcode: 146. LRU Cache

QuestionDesign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: getand put.get(key)- Get the value (will always be positive) of the key...

2019-06-04 10:49:51 106

原创 Leetcode: 332. Reconstruct Itinerary

Question:Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK...

2019-06-03 05:19:56 87

原创 Leetcode: 67. Add Binary

Question:Given two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters 1 or 0.Example 1:Input: a = “11”, b = “1”Output: “100...

2019-06-01 03:31:18 73

原创 Leetcode: 98. Validate Binary Search Tree

Question: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 nodes with keys less than the node’s k...

2019-05-30 09:24:30 79

原创 Leetcode 17: 17. Letter Combinations of a Phone Number

Question:Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.Example:Input: “23”Output: [“ad”, “ae”, “af”, “bd”, “be”, “bf...

2019-05-29 01:55:24 95

原创 Leetcode: 347. Top K Frequent Elements

Question:Given a non-empty array of integers, return the k most frequent elements.Example 1:Input: nums = [1,1,1,2,2,3], k = 2Output: [1,2]Solution 1: Priority Queuepublic class Element{ int ...

2019-05-28 11:34:33 59

原创 Leetcode: 283. Move Zeroes & 75. Sort Colors

Question:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.Example:Input: [0,1,0,3,12]Output: [1,3,12,0,0]Note...

2019-05-24 02:35:19 76

原创 Leetcode: 39. Combination Sum

QuestionGiven a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidateswhere the candidate numbers sums to target.The same...

2019-05-23 01:36:34 95

原创 Leetcode: 31. Next Permutation

Question:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest p...

2019-03-13 12:19:55 84

原创 Leetcode 2sum 3sum 4sum 总结

2 Sum 3 Sum and 4 Sum questions are similar, and the key of solving the problem is using 2 pointer.2 Sum:Question:Given an array of integers that is already sorted in ascending order, find two numb...

2019-03-13 09:55:26 93

原创 Leetcode: 16. 3Sum Closest

Question:Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each in...

2019-03-12 09:49:07 84

原创 Leecode: 15. Three Sums

Question:Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Solutionclass Solution { p...

2019-03-11 10:56:01 291

原创 Leetcode: 880. Decoded String at Index

Question:An encoded string S is given. To find and write the decoded string to a tape, the encoded string is read one character at a time and the following steps are taken:If the character read is ...

2019-03-03 17:22:13 221

原创 LeetCode: 856 Score of Parentheses

QuestionGiven a balanced parentheses string S, compute the score of the string based on the following rule:() has score 1AB has score A + B, where A and B are balanced parentheses strings.(A) has ...

2019-02-17 15:02:49 121

原创 lc 503: 503. Next Greater Element II

Question:Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The Next Greater Number of a number x is the...

2019-02-14 10:17:08 82

原创 Leetcode: 385. Mini Parser

Question:Each element is either an integer, or a list – whose elements may also be integers or other lists.Given a nested list of integers represented as a string, implement a parser to deserialize ...

2019-02-12 20:25:19 102

原创 Leetcode: 456. 132 Pattern

Question:Given a sequence of n integers a1, a2, …, an, a 132 pattern is a subsequence ai, aj, ak such that i < j < k and ai < ak < aj. Design an algorithm that takes a list of n numbers a...

2019-02-03 15:48:37 111

原创 Leetcode: 402. Remove K Digits

Question:Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible.Note:The length of num is less than 10002 and will...

2019-01-28 17:17:40 121

原创 Leetcode: 341. Flatten Nested List Iterator

Question:Given a nested list of integers, implement an iterator to flatten it.Each element is either an integer, or a list – whose elements may also be integers or other lists.Solution:/** * // T...

2019-01-28 13:21:18 120

原创 LeetCode: 331. Verify Preorder Serialization of a Binary Tree

Question:Given a string of comma separated values, verify whether it is a correct preorder traversal serialization of a binary tree. Find an algorithm without reconstructing the tree.Each comma sepa...

2019-01-27 12:43:23 90

原创 Leetcode: 173. Binary Search Tree Iterator

Question:mplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Solution:...

2019-01-27 11:35:02 122

原创 Leetcode: 138. Copy List with Random Pointer

Question:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.Solution1:public class So...

2019-01-20 18:38:43 100

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除