上一页 1 ··· 34 35 36 37 38 39 40 41 42 ··· 46 下一页

2014年11月13日

二分查找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 阅读(176) 评论(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 阅读(160) 评论(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 阅读(349) 评论(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 阅读(137) 评论(0) 推荐(0) 编辑

Dijkstra算法

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

posted @ 2014-11-11 23:17 luckygxf 阅读(197) 评论(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 阅读(188) 评论(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 阅读(149) 评论(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 阅读(123) 评论(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 阅读(129) 评论(0) 推荐(0) 编辑

Plus One

摘要: Plus OneGiven a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant dig... 阅读全文

posted @ 2014-11-10 20:55 luckygxf 阅读(178) 评论(0) 推荐(0) 编辑

上一页 1 ··· 34 35 36 37 38 39 40 41 42 ··· 46 下一页

导航