摘要: 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)
摘要: Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as1and0respectively in the grid.For example,There is one obstacle in the middle of a 3x3 grid as illustrated below.[ [0,0,0], [0,1, 阅读全文
posted @ 2013-08-19 23:27 懒猫欣 阅读(155) 评论(0) 推荐(0)
摘要: A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).How many possible uni 阅读全文
posted @ 2013-08-19 22:41 懒猫欣 阅读(180) 评论(0) 推荐(0)
摘要: Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should return length =5, and A is now[1,1,2,2,3].class Solution {public: int removeDuplicates(int A[], int n) { // Start typing your C/C++ solution be 阅读全文
posted @ 2013-08-15 15:09 懒猫欣 阅读(210) 评论(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-08-15 14:56 懒猫欣 阅读(154) 评论(0) 推荐(0)
摘要: class Solution {public: double pow(double x, int n) { if(n==1)return x; else if(n==-1)return 1/x; else if(n==0)return 1; else{ bool flag=n>0; if(!flag)n=-n; double ret=1; int bit=0x40000000; for(int i=0;i<31;i+... 阅读全文
posted @ 2013-08-15 13:53 懒猫欣 阅读(164) 评论(2) 推荐(0)
摘要: 分类器:Adaboost资源:UCI数据集:包括文本、图像、数据等CMU人脸demoUESTC人脸卡通数据库iiitd人脸卡通化 阅读全文
posted @ 2013-07-16 18:22 懒猫欣 阅读(150) 评论(0) 推荐(0)