摘要: Search Insert PositionGiven 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 order.You may assume no duplicates in the array.Here are few examples.[1,3,5,6], 5 → 2[1,3,5,6], 2 → 1[1,3,5,6], 7 → 4[1,3,5,6], 0 阅读全文
posted @ 2014-03-21 19:27 flowerkzj 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Rotate ListGiven a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL.就是给一个循环列表,有个头的链接,求转动k个位置后链接头的变化这里的话其实是要找出倒数第k个数的位置,然后在这个位置截开,后面链表接上前面链表的头。找出倒数第k个数首先思路用的是快慢指针。但是有一个需要考虑的就是k可以很大,因为 阅读全文
posted @ 2014-03-21 19:23 flowerkzj 阅读(194) 评论(0) 推荐(0) 编辑
摘要: Reverse Words in a StringGiven an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".单词反转,思路就是单词反转后再整句反转,只是加了一些要求,首尾的空格不能要,中间出现连续的空格都变成一个。 1 class Solution { 2 public: 3 void reverseAll(string &s, int i, int j) { 4 w 阅读全文
posted @ 2014-03-21 19:03 flowerkzj 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 一直都没有系统地看过一次Effective C++,最近好好地完整地读了一遍,收获颇丰,把读书笔记分享给大家看看,与大家交流交流~ 里面抄了书上不少的内容,也有一些个人的理解,可能有误,希望大家能及时指出~ 阅读全文
posted @ 2014-03-05 23:40 flowerkzj 阅读(306) 评论(0) 推荐(1) 编辑