- 博客(15)
- 资源 (12)
- 收藏
- 关注
原创 300. Longest Increasing Subsequence
Given an unsorted array of integers, find the length of longest increasing subsequence.For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The longest increasing subsequence is [2, 3, 7, 101], ther
2016-08-23 17:59:27
312
原创 Leetcode 343(Integer Break非动态规划求解)
问题 Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get. For example, given n = 2,
2016-04-20 10:27:52
645
原创 Leetcode 137: (Single Number II)
Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without us
2016-04-13 20:20:20
366
原创 Leetcode 142: Linked List Cycle II & Leetcode 287: Find the Duplicate Number
Leetcode 142: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list.解题思路:设置两个指针,一个快(fp), 一个慢(sp)。fp每次走两步,速度是2v2v,sp每
2016-04-13 13:48:55
321
原创 Leetcode 264(Ugly Number II)
QuestionWrite a program to find the nthn^{th} ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the
2015-08-19 13:31:36
839
原创 LeetCode 190(Reverse Bits)
QuestionReverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 001110
2015-08-18 10:51:01
695
原创 Leetcode201(Bitwise AND of Numbers Range)
QuestionGiven a range [m,n][m, n] where 0<=m<=n<=21474836470 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.For example, given the range [5,7][5, 7], you should
2015-08-16 23:44:26
420
原创 LeetCode 119(Pascal's Triangle II)
QuestionGiven an index k, return the kthk^{th} row of the Pascal’s triangle.For example, given k=3k = 3,Note:Could you optimize your algorithm to use only O(k) extra space?Analysis帕斯卡三角,也就是传说中的杨辉三角。其形状
2015-08-05 22:16:14
356
原创 Leetcode 134(Gas Station)
QuestionThere are N gas stations along a circular route, where the amount of gas at station ii is gas[i]gas[i].
2015-07-29 12:54:32
447
原创 Leetcode135(Candy)
Question原文引自> https://leetcode.com/problems/candy/There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requ
2015-07-28 22:30:59
439
原创 Leetcode 64(Minimum Path Sum)
Question: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 righ
2015-07-26 11:09:11
347
原创 LeetCode75(Sort Color)
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.
2015-07-21 23:14:36
431
原创 求解twitter面试题(墙壁装水问题)
看见twitter上一道面试题,题目是这样的,试着做了一下“在这个图片里我们有不同高度的墙。这个图片由一个整数数组所代表,数组中每个数是墙的高度。上边的图可以表示为数组[2,5,1,2,3,4,7,7,6]”“假如开始下雨了,那么墙之间的水坑能够装多少水呢?”思路分析:1. 找出该数组最大的元素(row);2. 将该数组以该最
2015-02-04 15:07:02
1123
原创 Dijkstra 算法示例
以上图作为示例,选取u为源点,然后计算u到其他顶点的最短距离。先假设dist[i]为u到i的最短路径的长度。\cost[x,y]表示x到y的权值。①找出与u相邻的顶点中距离最短的一条,得:dist[X]=1;②和u或者x的最短路径为cost[x,y]=1,所以dist[y]=cost(u,x)+cost(x,y)=2;③下个结点是w,dist[w]=min{cost(u,w),
2011-11-20 11:52:28
461
原创 关于robocode一些小感悟
<br /> 第一次认识robocode是在java课的课程设计上。第一次接触它,就深深的被他吸引住了,并由此开始了robocode的学习历程。<br /> 作为一个普通学生,对robocode的理解当然不能同研究robocode的众多专业人士相比较,所以自在这发表一些自己的粗浅言论,万望大家批评指教。<br /> 首先,可以毫无疑问的说robocode是一个及其好的学习java的工具。有很多人沉迷于QQ农场的一个重要原因就是因为其简单,易操作,更重要的是她和好友是互动的。roboco
2011-04-30 19:47:00
543
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人