摘要: 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) { // Start typing your C/C++ so... 阅读全文
posted @ 2013-05-18 17:51 NinaGood 阅读(85) 评论(0) 推荐(0) 编辑
摘要: Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3-/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} 阅读全文
posted @ 2013-05-18 16:31 NinaGood 阅读(119) 评论(0) 推荐(0) 编辑
摘要: #include<stack>class Solution {public: bool isValid(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function int len = s.size(); if( len == 0 ) { return false; } stack<char> my_sta... 阅读全文
posted @ 2013-05-18 14:37 NinaGood 阅读(600) 评论(0) 推荐(0) 编辑