望着时间滴答滴答的流过,我不曾改变过 . . .

随笔分类 -  算法

摘要:```java public int reverse(int x) { long res = 0; while (x != 0){ res = res 10 + x % 10; x /= 10; } if(res = Integer.MAX_VALUE || res 阅读全文
posted @ 2019-04-06 15:41 whyaza 阅读(132) 评论(0) 推荐(0)
摘要:```java public String longestPalindrome(String s) { String rs = ""; int res = 0; for(int i = 0; i= 0 && s.charAt(i) == s.charAt(left)) left --; while(right = 0 &... 阅读全文
posted @ 2019-04-06 11:57 whyaza 阅读(80) 评论(0) 推荐(0)
摘要:自己写的: java if(numRows == 1) return s; int ll = s.length() / 2 + 1; Character tc[] = new Character[numRows ll]; int i = 0, j = 0; boolean down = true; 阅读全文
posted @ 2019-04-06 10:59 whyaza 阅读(113) 评论(0) 推荐(0)
摘要:idea: 设置一个hashset存储非重复元素 j:遍历s i:最近的一个非重复指针 注意点: 1.Set set = new HashSet(); 2. add remove java public int lengthOfLongestSubstring(String s) { int i = 阅读全文
posted @ 2019-04-05 12:06 whyaza 阅读(82) 评论(0) 推荐(0)
摘要:注意点: 1. 最后的进位 2. (l1 == null || l1.next == null) 3. break; 阅读全文
posted @ 2019-04-04 19:45 whyaza 阅读(103) 评论(0) 推荐(0)
摘要:注意点: 1. HashMap 2. return new int[]{}; 3. 3 2 4 target:6 4. return null; java public int[] twoSum(int[] nums, int target) { HashMap m = new HashMap(); 阅读全文
posted @ 2019-04-04 18:45 whyaza 阅读(124) 评论(0) 推荐(0)
摘要:输出 if 语句 if...else... 语句 if...else if...else... 语句 while do...while for 三目运算 声明变量 int String, String int 判断string变量是否是数字 字符串的常见操作 char[] 与 String 的相互转 阅读全文
posted @ 2019-04-04 17:26 whyaza 阅读(271) 评论(0) 推荐(0)
摘要:本文转自豆瓣_燃烧的影子 图灵机与可计算性 图灵(1912~1954)出生于英国伦敦,19岁进入剑桥皇家学院研究量子力学和数理逻辑。1935年,图灵写出了“论高斯误差函数”的论文,因此他从一名学生直接成为学院的研究员,并开始了“可计算性”研究。1936年4月,图灵发表了“可计算数及其在判定问题上的一 阅读全文
posted @ 2018-10-08 19:02 whyaza 阅读(3315) 评论(0) 推荐(0)
摘要:八数码的问题描述为: 在3×3的棋盘上,摆有八个棋子,每个棋子上标有1至8的某一数字。棋盘中留有一个空格,空格用 1来表示。空格周围的棋子可以移到空格中。要求解的问题是:给出一种初始布局(初始状态)和目标布局,找到一种最少步骤的移动方法,实现从初始布局到目标布局的转变。 解决八数码的方法很多,本文采 阅读全文
posted @ 2018-09-20 21:58 whyaza 阅读(9619) 评论(0) 推荐(0)
摘要:在组合数学的这本书中,生成组合数字有很多中方法,比较常用的序数法,字典序法 本文采用字典序法,生成一堆组合数字,即C(n,r),从n个数字中取得r个,算法完整的定义如下: 从{1,2,…,n}中取r 组合表示为C1C2…Cr,令C1<C2<…<Cr,其中有i ≤Ci≤(n r+i), i=1,2,… 阅读全文
posted @ 2018-09-19 09:02 whyaza 阅读(1332) 评论(0) 推荐(0)