2017年6月8日

交换操作 swap

摘要: 一个类定义一个swap函数通常需要一次拷贝和两次赋值 例如 A类的两个对象v1与v2交换 A temp=v1; //copy构造一个临时对象 v1=v2; //赋值运算 v2=temp; //赋值运算 如果采用指针交换则可以减少一次拷贝构造 A* temp=v1; v1=v2; //赋值运算 v2= 阅读全文

posted @ 2017-06-08 22:29 kiplove 阅读(799) 评论(0) 推荐(0) 编辑

(leetcode题解)Can Place Flowers

摘要: Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they 阅读全文

posted @ 2017-06-08 21:09 kiplove 阅读(728) 评论(0) 推荐(0) 编辑

(leetcode题解)Reshape the Matrix

摘要: In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data. 阅读全文

posted @ 2017-06-08 19:52 kiplove 阅读(240) 评论(0) 推荐(0) 编辑

(leetcode题解)Search Insert Position

摘要: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文

posted @ 2017-06-08 16:51 kiplove 阅读(135) 评论(0) 推荐(0) 编辑

导航