- 博客(42)
- 资源 (1)
- 收藏
- 关注
原创 [leetcode] 563. Binary Tree Tilt
题目:Given a binary tree, return the tilt of the whole tree.The tilt of a tree node is defined as the absolute difference between the sum of all left subtree node values and the sum of all right sub...
2018-09-20 15:34:08 250
原创 [leetcode] 506. Relative Ranks
题目:Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal", "Silver Medal" and "Bronze Medal".Example 1:...
2018-09-20 15:17:46 285
原创 [leetcode] 447. Number of Boomerangs
题目:Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of t...
2018-09-16 18:27:52 273
原创 [leetcode] 733. Flood Fill
题目:An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535).Given a coordinate (sr, sc) representing the starting pixel (row and...
2018-09-16 17:30:34 347
原创 [leetcode] 492. Construct the Rectangle
题目:For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose len...
2018-09-16 17:06:24 130
原创 [leetcode] 598. Range Addition II
题目:Given an m * n matrix M initialized with all 0's and several update operations.Operations are represented by a 2D array, and each operation is represented by an array with two positiveintegers ...
2018-09-16 16:32:48 160
原创 [leetcode] 404. Sum of Left Leaves
题目:Find the sum of all left leaves in a given binary tree.Example: 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively. Retur...
2018-09-16 16:22:53 126
原创 [leetcode] 905. Sort Array By Parity
题目:Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A.You may return any answer array that satisfies this co...
2018-09-16 16:16:56 937
原创 [leetcode] 453. Minimum Moves to Equal Array Elements
题目:Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.Example:Input:[1,2,3]...
2018-09-14 22:12:28 119
原创 [leetcode] 783. Minimum Distance Between BST Nodes
题目:Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the values of any two different nodes in the tree.Example :Input: root = [4,2,6,1,3,null,null]...
2018-09-14 21:50:14 134
原创 [leetcode] 530. Minimum Absolute Difference in BST
题目:Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes.Example:Input: 1 \ 3 / 2Output:1Explanation...
2018-09-14 12:39:09 113
原创 [leetcode] 538. Convert BST to Greater Tree
题目:Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.E...
2018-09-14 12:21:32 115
原创 [leetcode] 796. Rotate String
题目:We are given two strings, A and B.A shift on A consists of taking string A and moving the leftmost character to the rightmost position. For example, if A = 'abcde', then it will be 'bcdea' afte...
2018-09-14 12:14:03 155
原创 [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 bills).Each customer will only buy one lemon...
2018-09-13 12:42:39 157
原创 [leetcode] 171. Excel Sheet Column Number
题目:Given a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -...
2018-09-13 12:36:55 126
原创 [leetcode] 653. Two Sum IV - Input is a BST
题目:Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.Example 1:Input: 5 / \ 3 6 / ...
2018-09-13 12:31:07 122
原创 [leetcode] 371. Sum of Two Integers
题目:Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example 1:Input: a = 1, b = 2Output: 3Example 2:Input: a = -2, b = 3Output: 1 代码:...
2018-09-11 12:59:06 116
原创 [leetcode] 389. Find the Difference
题目:Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that was...
2018-09-11 12:42:32 124
原创 [leetcode] 784. Letter Case Permutation
题目:Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create.Examples:Input: S = ...
2018-09-11 12:30:08 173
原创 [leetcode] 812. Largest Triangle Area
题目:You have a list of points in the plane. Return the area of the largest triangle that can be formed by any 3 of the points.Example:Input: points = [[0,0],[0,1],[1,0],[0,2],[2,0]]Output: 2Exp...
2018-09-11 10:36:29 158
原创 [leetcode] 429. N-ary Tree Level Order Traversal
题目:Given an n-ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example, given a 3-ary tree: We should return its level order t...
2018-09-10 13:03:52 120
原创 [leetcode] 892. Surface Area of 3D Shapes
题目:On a N * N grid, we place some 1 * 1 * 1 cubes.Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j).Return the total surface area of the resulting shapes....
2018-09-10 12:51:36 139
原创 [leetcode] 888. Fair Candy Swap
题目:Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, and B[j] is the size of the j-th bar of candy that Bob has.Since they are friends, th...
2018-09-10 12:07:38 179
原创 [leetcode] 292. Nim Game
题目:You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will b...
2018-09-10 11:01:15 115
原创 [leetcode] 897. Increasing Order Search Tree
题目:Given a tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only 1 right child.Example 1:Input: [5,3,6...
2018-09-10 10:37:22 384
原创 [leetcode] 762. Prime Number of Set Bits in Binary Representation
题目:Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary representation.(Recall that the number of set bits an int...
2018-09-09 15:44:13 107
原创 [leetcode] 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 repres...
2018-09-09 15:34:45 82
原创 [leetcode] 637. Average of Levels in Binary Tree
题目:Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array.Example 1:Input: 3 / \ 9 20 / \ 15 7Output: [3, 14.5, 11]Expl...
2018-09-09 15:27:38 80
原创 [leetcode] 104. Maximum Depth of Binary Tree
题目:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no ch...
2018-09-09 15:16:36 96
原创 [leetcode] 136. Single Number
题目:Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it witho...
2018-09-09 14:55:55 87
原创 [leetcode] 896. Monotonic Array
题目:An array is monotonic if it is either monotone increasing or monotone decreasing.An array A is monotone increasing if for all i <= j, A[i] <= A[j]. An array A is monotone decreasing if f...
2018-09-09 14:39:58 268
原创 [leetcode] 589. N-ary Tree Preorder Traversal
题目:Given an n-ary tree, return the preorder traversal of its nodes' values. For example, given a 3-ary tree: Return its preorder traversal as: [1,3,5,6,2,4]. Note: Recursive solution i...
2018-09-09 14:17:48 139
原创 [leetcode] 868. Binary Gap
题目:Given a positive integer N, find and return the longest distance between two consecutive 1's in the binary representation of N.If there aren't two consecutive 1's, return 0. Example 1:In...
2018-09-09 13:43:09 110
原创 [leetcode] 884. Uncommon Words from Two Sentences
题目:We are given two sentences A and B. (A sentence is a string of space separated words. Each word consists only of lowercase letters.)A word is uncommon if it appears exactly once in one of the...
2018-09-09 13:24:27 405
原创 [leetcode] 590. N-ary Tree Postorder Traversal
题目:Given an n-ary tree, return the postorder traversal of its nodes' values. For example, given a 3-ary tree: Return its postorder traversal as: [5,6,3,2,4,1]. Note: Recursive solution...
2018-09-09 12:20:49 164
原创 [leetcode] 893. Groups of Special-Equivalent Strings
题目:You are given an array A of strings.Two strings S and T are special-equivalent if after any number of moves, S == T.A move consists of choosing two indices i and j with i % 2 == j % 2, and sw...
2018-09-08 21:55:29 236
原创 [leetcode] 700. Search in a Binary Search Tree
题目:Given the root node of a binary search tree (BST) and a value. You need to find the node in the BST that the node's value equals the given value. Return the subtree rooted with that node. If such...
2018-09-08 21:00:54 122
原创 [leetcode] 872. Leaf-Similar Trees
题目:Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence.For example, in the given tree above, the leaf value sequence is (6,...
2018-09-07 11:47:53 101
原创 [leetcode] 559. Maximum Depth of N-ary Tree
题目:Given a n-ary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.For example, given a 3-ary tree:...
2018-09-07 10:36:07 125
原创 [leetcode] 876. Middle of the Linked List
题目;Given a non-empty, singly linked list with head node head, return a middle node of linked list.If there are two middle nodes, return the second middle node. Example 1:Input: [1,2,3,4,5]...
2018-09-06 15:10:30 122
C语言经典100例.pdf
2017-09-11
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人