摘要: Add Binary:Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". 题意:本题意思很明了,给定2个String,分别存储了用二进制表示的数,实现二进制的加法。 思路:从右向左逐位相加,注意进位即可。 代码: public S... 阅读全文
posted @ 2016-01-07 22:48 Lewisr 阅读(126) 评论(0) 推荐(0)
摘要: Contains Duplicate II: Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and ji... 阅读全文
posted @ 2016-01-07 22:36 Lewisr 阅读(873) 评论(0) 推荐(0)
摘要: Merge Sorted Array: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note: You may assume that nums1 has enough space (size that is greater or equal to m + n... 阅读全文
posted @ 2016-01-06 23:11 Lewisr 阅读(124) 评论(0) 推荐(0)
摘要: Majority Element: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You ma... 阅读全文
posted @ 2016-01-06 23:00 Lewisr 阅读(157) 评论(0) 推荐(0)
摘要: Move Zeros: Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For e... 阅读全文
posted @ 2016-01-06 22:50 Lewisr 阅读(124) 评论(0) 推荐(0)
摘要: Contains Duplicate:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false ... 阅读全文
posted @ 2016-01-05 19:22 Lewisr 阅读(148) 评论(0) 推荐(0)
摘要: Remove Element:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed.... 阅读全文
posted @ 2016-01-05 14:10 Lewisr 阅读(437) 评论(0) 推荐(0)
摘要: Plus One: Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant d... 阅读全文
posted @ 2016-01-05 13:47 Lewisr 阅读(173) 评论(0) 推荐(0)