
算法
xn_28
这个作者很懒,什么都没留下…
展开
-
【算法题】Leedcode 335. Self Crossing 自交问题
链接:https://leetcode.com/problems/self-crossing/解法参考:http://www.cnblogs.com/grandyang/p/5216856.html题目:You are given an array x of n positive numbers. You start at point (0,0) and m原创 2016-05-12 14:31:43 · 498 阅读 · 0 评论 -
【java】... 不定长度参数
链接:http://blog.chinaunix.net/uid-200142-id-3124427.html 在调用某个方法时,若是方法的参数个数事先无法确定该如何处理?例如System.out.printf()方法中并没有办法事先决定要给的参数个数,像是:?123System.out.printf(转载 2016-05-27 11:18:28 · 724 阅读 · 0 评论 -
【算法题】Leetcode 268. Missing Number 获取空缺数字
题目链接:https://leetcode.com/problems/missing-number/题目Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.For example, Given nums = [0, 1,原创 2016-06-15 10:30:40 · 437 阅读 · 0 评论 -
【算法题】Leedcode 273. Integer to English Words 用英文表示数字
题目链接:https://leetcode.com/problems/integer-to-english-words/题目Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 2^31 - 1. For example, 1原创 2016-06-15 17:37:02 · 627 阅读 · 0 评论 -
【算法题】网易编程题:暗黑字符串组合数
一个字符串仅由'A','B','C'三个字符组成,若字符串中不存在'A','B','C'三个字符相邻的子串(比如ABC,BAC等),则该字符串称为暗黑字符串,否则称为单纯字符串。求长度为L的此种字符串中有多少种是暗黑字符串?原创 2016-09-13 16:47:43 · 1387 阅读 · 0 评论 -
【算法题】找出且仅有的出现了奇数次的一个数
题目给你n个数,其中有且仅有一个数出现了奇数次,其余的数都出现了偶数次。用线性时间常数空间找出出现了奇数次的那一个数。解题思路关键字:异或从头到尾异或一遍,最后得到的那个数就是出现了奇数次的数。因为,两次异或同一个数,结果不变,且异或运算满足交换律。代码略原创 2016-09-19 05:00:00 · 2033 阅读 · 0 评论 -
KMP算法——字符串匹配
java实现和改进:http://blog.sina.com.cn/s/blog_85b0ae450101j2iy.htmlhttp://blog.youkuaiyun.com/pony_maggie/article/details/37832707http://blog.youkuaiyun.com/lin_bei/article/details/转载 2016-08-30 03:00:21 · 456 阅读 · 0 评论 -
【算法题】Leedcode 72
题目链接: https://leetcode.com/problems/edit-distance/解法参考: http://www.bubuko.com/infodetail-644271.htmlhttp://blog.sina.com.cn/s/blog_6f611c300101f72q.htmlhttp://blog.youkuaiyun.com/feliciafay/article/de原创 2016-05-26 11:29:19 · 641 阅读 · 0 评论 -
【算法题】洗牌算法(乱序)
题目将N个数乱序后输出,比如洗牌。解题思路:参考:http://www.cnblogs.com/hanxi/archive/2012/10/15/2725047.html随机生成法生成随机数,若已出现则重新生成,未出现则保存。随机交换法遍历有序数列,每一项与随机位置的元素交换,即可得到一个随机排列的数据列。转载 2016-10-10 17:26:42 · 3720 阅读 · 0 评论