- 博客(7)
- 收藏
- 关注
原创 LeetCode - Remove Duplicates from Sorted Array II
Question:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function should return length = 5, and A is
2014-02-26 21:11:18 360
原创 LeetCode - Remove Duplicates from Sorted Array
Question:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this
2014-02-26 20:59:15 370
原创 LeetCode - Remove Element
Question: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. It doesn't matter what you leave beyond the new length.
2014-02-26 20:16:26 395
原创 LeetCode - Reverse Integer
Question:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321利用%和/反转整型数字。代码如下:public int reverse(int x) { int xReverse = 0; whi
2014-02-26 19:17:05 383
原创 LeetCode - Single Number
Question:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it withou
2014-02-26 19:10:12 360
原创 LeetCode - Longest Substring Without Repeating Characters
用一个数组来存储每一个字符在字符串中的位置,数组的下标表示这个字符的ASCII码,元素表示其在字符串中的位置即可。如下图所示(转):代码如下所示:import java.util.ArrayList;import java.util.Arrays;import java.util.HashMap;import java.util.Map;import java.util.
2014-02-25 21:04:58 410
原创 LeetCode - Median of Two Sorted Arrays
在没有考虑效率的前提下:public static void main(String[] args) { // TODO Auto-generated method stub int A[] = {1,2,7}; int B[] = {4,5}; double median = findMedianSortedArrays(A, 3, B, 2); System.out.pri
2014-02-24 21:38:56 448
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人