LeetCode
文章平均质量分 75
我这知识都学杂了
这个作者很懒,什么都没留下…
展开
-
657. Judge Route Circle
Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place.The move sequence is represented原创 2017-09-30 00:59:53 · 141 阅读 · 0 评论 -
557. Reverse Words in a String III
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: "Let's take LeetCode contes原创 2017-09-30 01:23:41 · 126 阅读 · 0 评论 -
690. Employee Importance
You are given a data structure of employee information, which includes the employee's unique id, his importance value and his direct subordinates' id.For example, employee 1 is the leader of emp原创 2017-09-30 04:12:26 · 261 阅读 · 0 评论 -
680. Valid Palindrome II
Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome.Example 1:Input: "aba"Output: TrueExample 2:Input: "abca"Output: TrueEx原创 2017-09-30 23:59:25 · 221 阅读 · 0 评论 -
693. Binary Number with Alternating Bits
Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values.Example 1:Input: 5Output: TrueExplanation:The binary represen原创 2017-10-10 05:00:01 · 209 阅读 · 0 评论 -
695. Max Area of Island
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.) You may assume all four edges of the grid are su原创 2017-10-10 05:41:39 · 155 阅读 · 0 评论 -
482. License Key Formatting
You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string is separated into N+1 groups by N dashes.Given a number K, we would want to原创 2018-01-22 05:15:25 · 236 阅读 · 0 评论 -
415. Add Strings
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.Note:The length of both num1 and num2 is Both num1 and num2 contains only digits 0-9.Bo原创 2018-01-22 05:55:16 · 219 阅读 · 0 评论 -
225. Implement Stack using Queues
Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.empty() -- Return whet原创 2018-01-20 05:07:08 · 165 阅读 · 0 评论 -
232. Implement Queue using Stacks
Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front element.empty(原创 2018-01-20 05:17:35 · 164 阅读 · 0 评论 -
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 represented by empty parenthesis pair "()". And you原创 2017-07-26 23:31:10 · 671 阅读 · 0 评论 -
257. Binary Tree Paths
Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]使用DFS,因原创 2017-07-22 01:15:30 · 146 阅读 · 0 评论 -
188. Best Time to Buy and Sell Stock IV
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most k transactions.Note:You may no原创 2017-03-21 05:39:35 · 236 阅读 · 0 评论 -
309. Best Time to Buy and Sell Stock with Cooldown
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on原创 2017-03-21 07:09:16 · 160 阅读 · 0 评论 -
74. Search a 2D Matrix
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 from left to right.The first integer of each原创 2017-03-15 08:54:27 · 195 阅读 · 0 评论 -
143. Reorder List
关于链表问题,个人总结了几个考点,可以作为解题思路,今后也会补充。1. 找到链表的中点,可以使用快慢指针。2. 单链表翻转。3. 两个链表合并。-----------------------------------单链表中点------------------------------------------------------------------------原创 2016-09-26 01:10:16 · 214 阅读 · 0 评论 -
23. Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.ExampleGiven lists:[ 2->4->null, null, -1->null],return -1->2->4->null.Note: 题原创 2016-10-03 04:38:00 · 226 阅读 · 0 评论 -
124. Binary Tree Maximum Path Sum
Given a 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 node in the tree along the parent-child connections. The原创 2017-03-16 11:24:19 · 204 阅读 · 0 评论 -
461. Hamming Distance
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.Note:0 ≤ x,原创 2017-03-16 10:02:57 · 249 阅读 · 0 评论 -
300. Longest Increasing Subsequence
Given an unsorted array of integers, find the length of longest increasing subsequence.For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The longest increasing subsequence is [2, 3, 7, 101], ther原创 2017-03-16 07:24:13 · 183 阅读 · 0 评论 -
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 in the tree.这道题是利用一棵树的先序遍历,和中序遍历重建出一颗树,LeetCode中有一道相似的题目:106. Const原创 2017-03-17 01:17:21 · 301 阅读 · 0 评论 -
44. Wildcard Matching
Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover t原创 2017-03-17 05:46:03 · 328 阅读 · 0 评论 -
38. Count and Say
The count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211 is read off as "one 1" or 11.11 is read o原创 2018-01-20 06:00:23 · 165 阅读 · 0 评论