- 博客(11)
- 资源 (22)
- 收藏
- 关注
原创 LeetCode215. 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.
2016-09-16 12:22:17 426
原创 LeetCode34. Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm’s runtime complexity must be in the order of O(log n). If the target is not found in th
2016-09-15 21:00:16 306
原创 LeetCode278. First Bad Version
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the
2016-09-15 18:39:49 285
原创 LeetCode374. Guess Number Higher or Lower
We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wrong, I’ll tell you whether the number is higher or lo
2016-09-15 18:24:58 294
原创 leetcode 72. Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a word:
2016-09-15 14:53:17 565
原创 最长公共子序列
一个给定序列的子序列是在该序列中删去若干元素后得到的序列 给定两个序列X和Y,当另一序列Z既是X的子序列又是Y的子序列时,称Z是序列X和Y的公共子序列 最长公共子序列 X = (A, B, C, B, D, A, B) Y = (B, D, C, A, B, A) (B, C, B, A) (B, D, A, B)完全代码package org.fan.learn.dp;/**
2016-09-14 17:36:49 418
原创 LeetCode322. Coin Change
You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money c
2016-09-13 22:34:34 666
原创 01背包问题
小偷有一个容量为W的背包,有n件物品,第i个物品价值vi,且重wi 目标: 找到xi使得对于所有的xi = {0, 1} sum(wi*xi) <= W, 并且 sum(xi*vi)最大递归代码package org.fan.learn.dp;/** * Created by fan on 2016/9/13. */public class Bag { public static f
2016-09-13 18:48:18 368
原创 小兵向前冲
小兵向前冲N*M的棋盘上,小兵要从左下角走到右上角,只能向上或者向右走,问有多少种走法? 注意:这里说的N*M是指线段,而不是指几根竖线,几根横线。线段总是比线少1个的。下面的讨论都是基于线段的。 见下图(这个图是4*4的): 上图标注解释如下: 左下角黄色方框:起始位置 右上角黄色方框:目标位置 下边框和右边框黑色的数字0 1 2 3 4表示的是坐标 红色的方框:表示递归时的重复
2016-09-12 16:46:21 1555
原创 斐波那契数列与n!
实现斐波那契数列 0、1、1、2、3、5、8、13、21、34、…… F(0)=0,F(1)=1,F(n)=F(n-1)+F(n-2)(n≥2,n∈N*) 递归实现:package org.fan.learn.dp;/** * Created by fan on 2016/9/12. */public class Fibo { public static long[] result
2016-09-12 14:37:47 730
原创 leetcode198 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 houses
2016-09-12 10:55:49 388
keil uvision 3 注册机 带CID的
2013-01-23
hex转coe工具
2013-01-17
数据结构 严蔚敏 C语言版 括号匹配
2013-01-16
数据结构严蔚敏C语言版 迷宫
2013-01-16
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人