
leetcode
chongzi39
这个作者很懒,什么都没留下…
展开
-
leetcode 349. Intersection of Two Arrays
Pick One Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element in the result must be unique. The r原创 2017-10-07 11:48:00 · 173 阅读 · 0 评论 -
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. Example原创 2017-10-05 14:31:43 · 182 阅读 · 0 评论 -
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 added原创 2017-10-04 15:32:45 · 191 阅读 · 0 评论 -
leetcode 448. Find All Numbers Disappeared in an Array
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 array. Could原创 2017-10-04 11:32:02 · 142 阅读 · 0 评论 -
leetcode 258. Add Digits /371. Sum of Two Integers
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one di原创 2017-10-04 11:09:14 · 209 阅读 · 0 评论 -
leetcode 226. Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1镜像翻转 左子树和右子树交换,利用递归完成/** * Definition for a binary tree node. *原创 2017-10-03 17:57:25 · 150 阅读 · 0 评论 -
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.BFS或 DFS/** * Definition for a binary tr原创 2017-10-03 17:10:38 · 164 阅读 · 0 评论 -
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 7 Output: [3, 14.5, 11] Exp原创 2017-09-30 21:32:37 · 181 阅读 · 0 评论 -
leetcode 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 employe原创 2017-09-30 20:10:30 · 1134 阅读 · 0 评论 -
leetcode 682. Baseball Game
You’re now a baseball game point recorder. Given a list of strings, each string can be one of the 4 following types: Integer (one round’s score): Directly represents the number of points you get in原创 2017-09-30 17:54:22 · 1321 阅读 · 1 评论 -
leetcode-496. Next Greater Element I
/*You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1’s elements in the corresponding places of nums2.原创 2017-09-30 15:48:50 · 259 阅读 · 0 评论 -
513. Find Bottom Left Tree Value
Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input:2/ \ 1 3Output: 1Example 2: Input: 1 / \ 2 3 / / \4 5 6 / 7Output: 7Note:原创 2017-10-08 19:02:52 · 236 阅读 · 0 评论 -
leetcode 100. Same Tree
Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 递归实现/** * De原创 2017-10-08 18:59:04 · 225 阅读 · 0 评论 -
leetcode 105 /106 . Construct Binary Tree
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 tr原创 2017-10-08 18:56:49 · 228 阅读 · 0 评论 -
leetcode 169. Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element alway原创 2017-10-07 22:09:00 · 167 阅读 · 0 评论 -
leetcode 530. Minimum Absolute Difference in BST/404. Sum of Left Leaves/563. Binary Tree Tilt
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: The min原创 2017-10-07 12:24:35 · 205 阅读 · 0 评论 -
leetcode 492. Construct the Rectangle
Pick One 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原创 2017-10-05 15:35:41 · 182 阅读 · 0 评论