摘要: 1 public int myAtoi(String str) { 2 long value = 0; 3 char sign = '\0'; 4 //是否已经存在非零值,存在true,不存在false 5 boolean existNonzero = false; 6 boolean over = fa... 阅读全文
posted @ 2017-05-17 22:04 zouxiaochuan 阅读(165) 评论(0) 推荐(0)
摘要: 更直接简便的解法: Z字形排列之后,每一行元素在原字符串中的位置就是一组(首尾两行)或两组(中间)等差数列 阅读全文
posted @ 2017-05-15 21:09 zouxiaochuan 阅读(127) 评论(0) 推荐(0)
摘要: 1 public String longestPalindrome(String s) { 2 char[] ch = s.toCharArray(); 3 int longestLength = 0; 4 int[] longestIndex = {0, 0}; 5 for(int i = 0; i k && (i +... 阅读全文
posted @ 2017-05-15 12:56 zouxiaochuan 阅读(128) 评论(0) 推荐(0)
摘要: 1 public int lengthOfLongestSubstring(String s) { 2 char[] chars = s.toCharArray(); 3 //存储已遍历的元素中相应char值最后出现的位置 4 HashMap map = new HashMap(); 5 //当遍历到i位置时,lastNoRepeatIndex到i是已遍... 阅读全文
posted @ 2017-05-14 12:48 zouxiaochuan 阅读(148) 评论(0) 推荐(0)
摘要: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ex 阅读全文
posted @ 2017-05-12 20:45 zouxiaochuan 阅读(168) 评论(0) 推荐(0)