摘要:
Given a linked list, remove thenthnode 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 list becomes 1->2->3->5.Note:Givennwill always be valid.Try to do this in one pass./* 阅读全文
posted @ 2013-08-20 01:43
懒猫欣
阅读(164)
评论(0)
推荐(0)
摘要:
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.class Solution {public: int removeElement(int A[], int n, int elem) { int ptr=n-1; int lengt... 阅读全文
posted @ 2013-08-20 01:23
懒猫欣
阅读(181)
评论(0)
推荐(0)
摘要:
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3->3->4->4->5, return1->2->5.Given1->1->1->2->3, return2->3./** * Definition for singly-linked list. * struct Lis 阅读全文
posted @ 2013-08-20 01:03
懒猫欣
阅读(132)
评论(0)
推荐(0)
摘要:
Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, return1->2->3./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val 阅读全文
posted @ 2013-08-20 00:52
懒猫欣
阅读(145)
评论(0)
推荐(0)
浙公网安备 33010602011771号