LeetCode练习笔记
文章平均质量分 64
Practice makes Perfect !
月牙儿June
业精于勤荒于嬉,Practice makes perfect!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
动态规划(DP)问题分析汇总
问题一: 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,原创 2017-03-14 11:07:53 · 542 阅读 · 0 评论 -
贪心Greedy
先看一下这个问题: LeetCode 55. Jump Game Question Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents yo原创 2017-03-15 10:54:42 · 391 阅读 · 0 评论 -
LeetCode 75 Sort Colors
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers原创 2017-04-09 21:55:43 · 569 阅读 · 2 评论 -
leetcode 练习——add two numbers (Java)
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ public class Solution { public ListNode addT原创 2016-03-10 21:01:20 · 435 阅读 · 0 评论 -
Dynamic Programming 动态规划问题 DP
动态规划问题通过利用重叠子问题,优化子结构,以空间换时间,来达到优化时间复杂度的目的。 分类 主要分为两大类:自顶向下Top-down(经常被称作:memorization); 自底向上Bottom-Up. 一、memoization(TOp-Down): 例如求斐波那契数列fib(5),过程如下: 相同的计算过程一直再重复,为了避免重复,我们可以把已经计算过的结果原创 2016-06-13 11:27:25 · 1361 阅读 · 0 评论 -
leetcde练习——Implement strStr()
Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 我的思路: 暴力方法,简单直接。 从字符串haystack的第一个字符开始,从左至右依次匹配它的子串(同needle比较)。原创 2016-06-20 10:19:42 · 483 阅读 · 0 评论 -
LeetCode 101. Symmetric Tree
分类 :Tree; BFS; DFS 问题描述: 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原创 2016-11-29 19:55:57 · 291 阅读 · 0 评论 -
LeetCode 100. Same Tree
分类:Tree ;DFS 问题描述: 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原创 2016-11-29 20:38:32 · 301 阅读 · 0 评论 -
LeetCode 27. Remove Element
分类: Array ; Two Points 问题描述: Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you must do this原创 2016-11-30 21:31:27 · 407 阅读 · 0 评论
分享