算法
YlCICI
这个作者很懒,什么都没留下…
展开
-
Leetcode 169.Majority Element
169. Majority ElementGiven 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-empt原创 2017-09-10 18:01:45 · 202 阅读 · 0 评论 -
Leetcode 101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the原创 2018-01-18 15:59:30 · 154 阅读 · 0 评论 -
100. Same Tree
Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.Example 1:In原创 2018-01-18 15:56:52 · 140 阅读 · 0 评论 -
Leetcode 112. Path Sum
Leetcode 112. Path SumGiven 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 t原创 2018-01-07 21:34:41 · 172 阅读 · 0 评论 -
Leetcode 257. Binary Tree Paths
iven 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"]递归实现DF原创 2018-01-08 15:28:05 · 148 阅读 · 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).For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 2原创 2018-01-08 15:59:30 · 183 阅读 · 0 评论 -
Leetcode 240. 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 in原创 2018-01-07 23:31:01 · 121 阅读 · 0 评论 -
Leetcode 53. 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原创 2018-01-07 23:06:13 · 181 阅读 · 0 评论 -
Leetcode 122. Best Time to Buy and Sell Stock II
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原创 2018-01-07 22:15:37 · 165 阅读 · 0 评论 -
Leetcode 455. Assign Cookies
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a c原创 2018-01-07 22:02:53 · 153 阅读 · 0 评论 -
94. Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2].使用栈模拟递归过程,完成遍历,时间复杂度0(n)class Solution {原创 2018-01-18 16:15:48 · 146 阅读 · 0 评论