leetcode 1049 Last Stone Weight II(最后一块石头的重量 II)
摘要:``` 有一堆石头,每块石头的重量都是正整数。 每一回合,从中选出任意两块石头,然后将它们一起粉碎。假设石头的重量分别为 x 和 y,且 x & stones) { int sum = 0; for (int i = 0; i
阅读全文
posted @
2019-05-20 00:52
Beserious
阅读(918)
推荐(0) 编辑
leetcode 最受欢迎的91道题目
摘要:根据like排序取的前91道题目 转载请注明出处 1. "leetcode 461. Hamming Distance" 2. "leetcode 617. Merge Two Binary Trees" 3. "leetcode 338. Counting Bits" 4. "leetcode 4
阅读全文
posted @
2018-11-18 10:09
Beserious
阅读(821)
推荐(0) 编辑
leetcode 910. Smallest Range II
摘要:Given an array A of integers, for each integer A[i] we need to choose either x = K or x = K, and add x to A[i] (only once). After this process, we hav
阅读全文
posted @
2018-09-24 19:14
Beserious
阅读(407)
推荐(0) 编辑
leetcode 908. Smallest Range I
摘要:Given an array A of integers, for each integer A[i] we may choose any x with K & A, int K) { int a = INT_MAX; int b = INT_MIN; for (int i = 0; i
阅读全文
posted @
2018-09-24 16:08
Beserious
阅读(142)
推荐(0) 编辑
leetcode 900. RLE Iterator
摘要:Write an iterator that iterates through a run length encoded sequence. The iterator is initialized by RLEIterator(int[] A), where A is a run length en
阅读全文
posted @
2018-09-09 15:20
Beserious
阅读(260)
推荐(0) 编辑
leetcode 901. Online Stock Span
摘要:Write a class StockSpanner which collects daily price quotes for some stock, and returns the span of that stock's price for the current day. The span
阅读全文
posted @
2018-09-09 15:19
Beserious
阅读(269)
推荐(0) 编辑
leetcode 102. Binary Tree Level Order Traversal
摘要:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). bfs层序遍历整颗树。
阅读全文
posted @
2018-09-03 16:48
Beserious
阅读(180)
推荐(0) 编辑
leetcode 72. Edit Distance
摘要:Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitt
阅读全文
posted @
2018-09-02 12:13
Beserious
阅读(173)
推荐(0) 编辑
leetcode 406. Queue Reconstruction by Height
摘要:Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the pers
阅读全文
posted @
2018-09-01 11:44
Beserious
阅读(148)
推荐(0) 编辑
leetcode 889. Spiral Matrix III
摘要:On a 2 dimensional grid with R rows and C columns, we start at (r0, c0) facing east. Here, the north west corner of the grid is at the first row and c
阅读全文
posted @
2018-08-12 11:35
Beserious
阅读(409)
推荐(0) 编辑
leetcode 890. Possible Bipartition
摘要:Given a set of N people (numbered 1, 2, ..., N), we would like to split everyone into two groups of any size. Each person may dislike some other peopl
阅读全文
posted @
2018-08-12 11:30
Beserious
阅读(213)
推荐(0) 编辑
leetcode 142. Linked List Cycle II
摘要:题目要求不修改链表结构,同时不用额外的内存,去找到链表中环的起点。 我们可以通过快慢指针很容易判断有没有环,接下来,再把快指针的步伐也变为1并从head开始走,那么快慢指针再次相遇对应的指针就是环的起点。 解释:可以把问题抽象成一个直线和圈的结构, 粉色点表示相遇点,那么快指针走过a+b+c+b,慢
阅读全文
posted @
2018-07-16 19:43
Beserious
阅读(124)
推荐(0) 编辑
leetcode 152. Maximum Product Subarray
摘要:Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. 题意:求最大的连乘。 思
阅读全文
posted @
2018-07-11 21:06
Beserious
阅读(129)
推荐(0) 编辑
leetcode 860. Lemonade Change
摘要:At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bil
阅读全文
posted @
2018-07-01 14:49
Beserious
阅读(253)
推荐(0) 编辑
leetcode 863. All Nodes Distance K in Binary Tree
摘要:We are given a binary tree (with root node root), a target node, and an integer value . Return a list of the values of all nodes that have a distance
阅读全文
posted @
2018-07-01 11:44
Beserious
阅读(670)
推荐(0) 编辑
leetcode 856. Score of Parentheses
摘要:Given a balanced parentheses string S, compute the score of the string based on the following rule: Example 1: Input: "()" Output: 1 Example 2: Input:
阅读全文
posted @
2018-06-24 14:40
Beserious
阅读(400)
推荐(0) 编辑
leetcode 859. Buddy Strings
摘要:Given two strings A and B of lowercase letters, return true if and only if we can swap two letters in A so that the result equals B. 题目大意:给出A,B两个字符串,问
阅读全文
posted @
2018-06-24 11:23
Beserious
阅读(400)
推荐(0) 编辑
leetcode 650. 2 Keys Keyboard
摘要:Initially on a notepad only one character 'A' is present. You can perform two operations on this notepad for each step: Copy All: You can copy all the
阅读全文
posted @
2018-04-04 23:21
Beserious
阅读(202)
推荐(0) 编辑
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 maxim
阅读全文
posted @
2018-04-03 13:39
Beserious
阅读(141)
推荐(0) 编辑
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 in the tree. 思路还是比较简单的,在中
阅读全文
posted @
2018-03-26 22:04
Beserious
阅读(104)
推荐(0) 编辑