摘要:
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++ ... 阅读全文
posted @ 2013-04-24 17:04
冰点猎手
阅读(272)
评论(0)
推荐(0)
摘要:
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the following is not: 1 / \ 2 2 \ \ 3 3Note:Bonus points if you could solve it both recursive... 阅读全文
posted @ 2013-04-24 12:36
冰点猎手
阅读(135)
评论(0)
推荐(0)
摘要:
Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space to hold additional elements from B. The number of elements initialized in A and B are m and n respectively. class Solution {public: void merge(int A[], int m, int B[], int n) {... 阅读全文
posted @ 2013-04-24 12:10
冰点猎手
阅读(146)
评论(0)
推荐(0)
摘要:
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class ... 阅读全文
posted @ 2013-04-24 11:58
冰点猎手
阅读(151)
评论(0)
推荐(0)