Fork me on GitHub
上一页 1 2 3 4 5 6 7 8 9 10 ··· 26 下一页
摘要: 函数作为返回值 可变参数的求和 可以不返回求和的结果,而是返回求和的函数: 不需要立刻求和,而是在后面的代码中,根据需要再计算 闭包 注意到返回的函数在其定义内部引用了局部变量args,所以,当一个函数返回了一个函数后,其内部的局部变量还被新函数引用,所以,闭包用起来简单,实现起来可不容易。另一个需 阅读全文
posted @ 2019-08-13 14:06 cznczai 阅读(264) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int movesToMakeZigzag(int[] nums) { int temp1[] = new int[nums.length]; int temp2[] = new int[nums.length]; for (int i = 0; i 阅读全文
posted @ 2019-08-10 17:52 cznczai 阅读(202) 评论(0) 推荐(0) 编辑
摘要: class Node { final static int the_maxsize = 26; Node[] list = new Node[the_maxsize]; char data; boolean isEnd = false; //用isEnd 代替isSelf 节约空间 } class 阅读全文
posted @ 2019-08-10 17:01 cznczai 阅读(83) 评论(0) 推荐(0) 编辑
摘要: 暴力 class Solution { public int lengthOfLongestSubstring(String s) { int the_max = 0; HashSet hs = new HashSet(); for (int i = 0; i hs = new HashSet(); 阅读全文
posted @ 2019-08-10 15:41 cznczai 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 遍历中心点 然后像两边扩出去 class Solution { public String longestPalindrome(String s) { String ans =""; for(int i = 0 ; i =0&&y=0&&y 阅读全文
posted @ 2019-08-08 16:01 cznczai 阅读(116) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int numUniqueEmails(String[] emails) { HashSet hs = new HashSet(); for (int i = 0; i hs = new HashSet(); for (String i : email 阅读全文
posted @ 2019-08-08 14:35 cznczai 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 今天项目里遇到以"." 、"\"、“|”分割字符串,直接用"." 、"\"、“|”无法分割,因为"." 、"\"、“|”是特殊字符,需要转义,"\\." 、"\\\"、“\\|”。 精简~ class Solution { public int compareVersion(String s1, S 阅读全文
posted @ 2019-08-08 12:45 cznczai 阅读(79) 评论(0) 推荐(0) 编辑
摘要: ![](https://img2018.cnblogs.com/blog/1648545/201908/1648545-20190807170036698-2003229138.png) ``` class Solution { public String reverseWords(String s) { StringBuffer ans = new StringBuff... 阅读全文
posted @ 2019-08-07 23:46 cznczai 阅读(70) 评论(0) 推荐(0) 编辑
摘要: 在美版leetcode上看到大神的思路,用质数表示26个字母,把字符串的各个字母相乘,这样可保证字母异位词的乘积必定是相等的。其余步骤就是用map存储,和别人的一致了。(这个用质数表示真的很骚啊!!!) 阅读全文
posted @ 2019-08-07 15:48 cznczai 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 函数式编程的一个特点就是,允许把函数本身作为参数传入另一个函数,还允许返回一个函数! Python对函数式编程提供部分支持。由于Python允许使用变量,因此,Python不是纯函数式编程语言。 传入函数 既然变量可以指向函数,函数的参数能接收变量,那么一个函数就可以接收另一个函数作为参数,这种函数 阅读全文
posted @ 2019-08-07 10:56 cznczai 阅读(220) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 26 下一页