摘要: 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. 1 class Solution { 2 public: 3 int removeElement(int A[], int n, int elem) { 4 // Start typing y... 阅读全文
posted @ 2013-05-13 20:39 infinityu 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.For example,Given input array A =[1,1,2],Your function should return length =2, and A is 阅读全文
posted @ 2013-05-13 20:24 infinityu 阅读(150) 评论(0) 推荐(0) 编辑
摘要: Write a function to find the longest common prefix string amongst an array of strings. 1 class Solution { 2 public: 3 string longestCommonPrefix(vector<string> &strs) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 stringstream rtn; 7... 阅读全文
posted @ 2013-05-13 19:14 infinityu 阅读(259) 评论(0) 推荐(0) 编辑