摘要: (231)-(Power of Two)-(判断一个整数他是不是2的多少次方)-(一直除以2就好了,注意1和0这种特殊情况)//Given an integer,//write a function to determine if it is a power of twopublic class S... 阅读全文
posted @ 2015-07-25 19:33 爱吃萝卜干 阅读(123) 评论(0) 推荐(0) 编辑
摘要: (220)-(Contains Duplicate III)-(判断数组中是否位置差至多为k时,值差最多为t)-(特殊解法,用treeset中的floor和ceiling)//Given an array of integers, //find out whether there are two d... 阅读全文
posted @ 2015-07-25 19:31 爱吃萝卜干 阅读(217) 评论(0) 推荐(0) 编辑
摘要: (219)-(Contains Duplicate II)-(判断数组中出现重复值的两个元素,位置差最多为k)-(HashSet及时删除元素)//Given an array of integers and an integer k,//find out whether there there ar... 阅读全文
posted @ 2015-07-25 19:30 爱吃萝卜干 阅读(129) 评论(0) 推荐(0) 编辑
摘要: (217)-(Contains Duplicate)-(数组中是否包含重复值)-(HashSet进行处理)//Given an array of integers, find if the array contains any duplicates.//Your function should re... 阅读全文
posted @ 2015-07-25 19:27 爱吃萝卜干 阅读(105) 评论(0) 推荐(0) 编辑
摘要: (7)-(Reverse Integer)-(将整数按位反转成另外一个整数,考虑溢出)-(知道最大整数和最小整数值)//Reverse digits of an integer.//Example1: x = 123, return 321//Example2: x = -123, return -... 阅读全文
posted @ 2015-07-25 19:26 爱吃萝卜干 阅读(112) 评论(0) 推荐(0) 编辑
摘要: (88)-(Merge Sorted Array )-(将两个有序的数组合并成同一个数组nums1)-(还是归并排序的最后一步)//You may assume that nums1 has enough space //(size that is greater or equal to m + n... 阅读全文
posted @ 2015-07-25 19:26 爱吃萝卜干 阅读(93) 评论(0) 推荐(0) 编辑
摘要: (5)-(Longest Palindromic Substring )-(最长回文字串)-(特殊解法,)//Given a string S, find the longest palindromic substring in S.//You may assume that the maximum... 阅读全文
posted @ 2015-07-25 19:25 爱吃萝卜干 阅读(84) 评论(0) 推荐(0) 编辑
摘要: (6)-(ZigZag Conversion)-(字符串按照某种规则进行输出)-(StringBuffer存各行内容)//The string "PAYPALISHIRING" is written in a zigzag pattern //on a given number of rows li... 阅读全文
posted @ 2015-07-25 19:25 爱吃萝卜干 阅读(89) 评论(0) 推荐(0) 编辑
摘要: (4)-(Median of Two Sorted Arrays)-(找两个有序数组的中位数)-(归并排序的最后一步,两个数组合并)//There are two sorted arrays nums1 and nums2 of size m and n respectively. //Find t... 阅读全文
posted @ 2015-07-25 19:19 爱吃萝卜干 阅读(174) 评论(0) 推荐(0) 编辑
摘要: (2)-(Add Two Numbers)-(将两个ListNode表示的整树进行按位加)-(ListNode的遍历)Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)Output: 7 -> 0 -> 8//这里考察单链表的尾插法://首先,申请内存final_ans//r_... 阅读全文
posted @ 2015-07-25 19:14 爱吃萝卜干 阅读(465) 评论(0) 推荐(0) 编辑