- 博客(15)
- 收藏
- 关注
原创 Depth-first Search -- Leetcode problem113. Path Sum II
描述:Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum.For example: Given the below binary tree and sum = 22, 5 / \ 4 8
2017-09-24 16:37:59 186
原创 Depth-first Search -- Leetcode problem112. Path Sum
描述:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example: Given the below binary tree and sum
2017-09-24 10:46:13 216
原创 Depth-first Search -- Leetcode problem100. 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.分析:判断两棵树是否相等,水
2017-09-24 09:45:19 190
原创 Depth-first Search -- Leetcode problem104. 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.树的结构: /** Definition for a binar
2017-09-23 14:37:32 198
原创 Hash Table -- Leetcode problem676. Implement Magic Dictionary
描述:Implement a magic directory with buildDict, and search methods.For the method buildDict, you’ll be given a list of non-repetitive words to build a dictionary.For the method search, you’ll be given
2017-09-22 15:31:39 290
原创 Array -- Leetcode problem1. Two Sum
描述:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same
2017-09-22 13:17:28 170
原创 Hash Table -- Leetcode problem350. Intersection of Two Arrays II
描述:Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note: Each element in the result should appear as many times as
2017-09-21 19:22:09 146
原创 Hash Table -- Leetcode problem349. Intersection of Two Arrays
描述: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 result can b
2017-09-21 19:12:57 129
原创 Hash Table -- Leetcode problem454. 4Sum II
描述:Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.To make problem a bit easier, all A, B, C, D have same leng
2017-09-21 14:00:19 143
原创 Divide and Conquer -- Leetcode problem53. Maximum Subarray
描述:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2,1] has
2017-09-20 13:19:07 446
原创 Divide and Conquer -- Leetcode problem240. 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 i
2017-09-18 13:37:35 610
原创 Divide and Conquer -- Leetcode problem215: Kth Largest Element in an Array
描述:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Example, Given [3,2,1,5,6,4] and k = 2, return 5. Note
2017-09-17 10:25:50 367
原创 Hash Table -- Leetcode problem500:Keyboard Row
描述:Given a List of words, return the words that can be typed using letters of alphabet on only one row’s of American keyboard like the image below. Example 1: Input: [“Hello”, “Alaska”, “Dad”, “Peace
2017-09-15 14:51:51 169
原创 Divide and Conquer -- Leetcode problem241:Different Ways to Add Parentheses
描述:Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *.
2017-09-13 10:30:42 205
原创 Divide and Conquer -- Leetcode problem169: 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 alw
2017-09-08 13:43:23 479
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人