算法分析与设计
文章平均质量分 62
SYSUJackJiao
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
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原创 2018-01-12 18:01:16 · 244 阅读 · 0 评论 -
LeetCode 70. Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n will be a posi原创 2018-01-13 23:25:35 · 352 阅读 · 0 评论 -
LeetCode 64. Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or right at原创 2018-01-13 23:13:20 · 313 阅读 · 0 评论 -
LeetCode 455. Assign Cookies
class Solution { public: int findContentChildren(vector& g, vector& s) { int count = 0; sort(g.begin(),g.end()); sort(s.begin(),s.end()); int j = 0 , i = 0;原创 2018-01-13 18:25:26 · 236 阅读 · 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-13 17:51:38 · 253 阅读 · 0 评论 -
LeetCode 199. Binary Tree Right Side View
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For example: Given the following binary tree, 1原创 2018-01-13 17:25:58 · 290 阅读 · 0 评论 -
LeetCode 111. Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 解法:利用递归 /** * Definition for a原创 2018-01-13 16:55:04 · 274 阅读 · 0 评论 -
LeetCode 112. 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原创 2018-01-13 15:25:39 · 350 阅读 · 0 评论 -
LeetCode 113. 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 / \原创 2018-01-13 16:06:05 · 241 阅读 · 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 3原创 2018-01-13 14:30:25 · 401 阅读 · 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]原创 2018-01-13 13:37:35 · 275 阅读 · 0 评论 -
LeetCode 215. 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. For example, Given [3,2,1,5,6,4] and k = 2, return 5原创 2018-01-12 22:50:34 · 309 阅读 · 0 评论 -
LeetCode 1.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 sam原创 2017-09-13 12:21:18 · 342 阅读 · 0 评论 -
LeetCode 198. House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house原创 2018-01-13 23:41:13 · 301 阅读 · 0 评论
分享