上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 49 下一页

2014年11月13日

动态规划(DP)

摘要: 动态规划,Dynamic programming,不是Dynamic planning ...将问题分成若干子问题,前面的解为后面的解所用,注意逆向推倒,找出递推公式,经典的01背包问题,晚点实现一下,这里搞一个LeetCode上面的题放着记录一下神马求二项式系数,斐波拉契...都可以用动态规划来实... 阅读全文

posted @ 2014-11-13 15:24 luckygxf 阅读(194) 评论(0) 推荐(0)

二分查找or折半查找

摘要: 1 package com.gxf.search; 2 3 /** 4 * 测试折半查找or二分查找 5 * @author xiangfei 6 * 7 */ 8 public class BiSearch { 9 10 /**11 * 非递归实现,从第1个元... 阅读全文

posted @ 2014-11-13 00:09 luckygxf 阅读(182) 评论(0) 推荐(0)

2014年11月12日

Climbing Stairs

摘要: Climbing StairsYou are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct way... 阅读全文

posted @ 2014-11-12 15:38 luckygxf 阅读(168) 评论(0) 推荐(0)

静态查找

摘要: 静态查找设置哨兵,可以减少比较次数,效率会有所提高。静态查找算法简单,效率较低 1 package com.gxf.search; 2 3 /** 4 * 静态查找实现 5 * @author xiangfei 6 * 7 */ 8 public class StaticSearch { ... 阅读全文

posted @ 2014-11-12 13:05 luckygxf 阅读(367) 评论(0) 推荐(0)

2014年11月11日

Length of Last Word

摘要: Length of Last WordGiven a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.I... 阅读全文

posted @ 2014-11-11 23:29 luckygxf 阅读(145) 评论(0) 推荐(0)

Dijkstra算法

摘要: Dijkstra算法又称单源点距离最短问题设一个图中有V0,V1,V2,V3...等顶点,这里设求的是V0到V1,V2,...的最短距离基本思想V0到剩余顶点的直接距离dist[](不经过其他任何节点,没有联通的设为无穷大)中,找出一个最小的,设其顶点为V1,这里我们就求出了V0到V1的最短距离。将... 阅读全文

posted @ 2014-11-11 23:17 luckygxf 阅读(207) 评论(0) 推荐(0)

Valid Parentheses

摘要: Valid ParenthesesGiven a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must clos... 阅读全文

posted @ 2014-11-11 20:53 luckygxf 阅读(196) 评论(0) 推荐(0)

Java泛型

摘要: 感觉和c++的模板很类似,这里记录一下基本的认识 1 public class Test { 2 private T obj; 3 public Test(T obj){ 4 this.obj = obj; 5 } 6 public T getObj(... 阅读全文

posted @ 2014-11-11 15:24 luckygxf 阅读(154) 评论(0) 推荐(0)

Remove Duplicates from Sorted Array

摘要: Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new lengt... 阅读全文

posted @ 2014-11-11 11:11 luckygxf 阅读(134) 评论(0) 推荐(0)

2014年11月10日

Add Binary

摘要: Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100". 1 public class Solution { 2 publ... 阅读全文

posted @ 2014-11-10 21:37 luckygxf 阅读(138) 评论(0) 推荐(0)

上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 49 下一页

导航