- 博客(11)
- 收藏
- 关注
原创 83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3.pointer ->temp, when pointer cha
2016-07-28 11:11:34
216
原创 27. Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.The order
2016-07-26 10:57:44
206
转载 203.Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.Example Given: 1 –> 2 –> 6 –> 3 –> 4 –> 5 –> 6, val = 6 Return: 1 –> 2 –> 3 –> 4 –> 5两个指针,等于哪个删哪个public class Solution { pub
2016-07-26 09:53:37
212
原创 19. Remove Nth Node From End of List
题目: Given a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the linked li
2016-07-15 13:27:20
204
原创 234. Parlindrome Linked List
Given a singly linked list, determine if it is a palindrome.Follow up: Could you do it in O(n) time and O(1) space?之前想过的一个方法是先将其看成是判断Parlindrome 的string来做,将Linked List里的数取出来转换成string来判断,但是有问题:一是linked
2016-07-14 14:30:12
392
原创 Palindrome Numer
题目:Determine whether an integer is a palindrome. Do this without extra space. 不使用其它空间的意思是不是不调用其它函数??… Palindrome integer就是说正看倒看都是一样的整数。比如23432,121等。 题目给的提示有:负数是否可以成为回文?给出的答案是不能。这也就意味着0可以。在考虑number r
2016-07-08 23:34:01
277
原创 Zigzag
题目:The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H N A P L S I I
2016-07-08 18:57:49
266
原创 AddTwoNumber
题目:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a li
2016-07-08 11:02:01
372
原创 TwoSum
题目: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1].try:public class Solution { public int[] twoSum(int[] nums, int target) { int sum=0;
2016-07-07 15:34:26
242
原创 ReverseInteger
Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321除了考虑数字的翻转之外,还有溢出的判断。int 32bit -2147483648~21373836471st:public class Solution { public static int revers
2016-07-07 11:46:44
207
原创 codehunt 1.10
public class Program { public static int Puzzle(int x, int y) { int z=x+y/3; return z; }}int + 5+3=8int - 5-3=2int * 5*3=15int / 5/3=1int %
2016-04-21 14:46:56
564
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅