摘要: No.135 CandyThere areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the fol... 阅读全文
posted @ 2015-05-27 11:59 人生不酱油 阅读(286) 评论(0) 推荐(0) 编辑
摘要: No.42 Trapping Rain WaterGivennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able... 阅读全文
posted @ 2015-05-26 16:31 人生不酱油 阅读(197) 评论(0) 推荐(0) 编辑
摘要: No.149 Max Point on a LineGivennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.尝试1:考虑不周,一条直线上的点会重复计数,但没找到解... 阅读全文
posted @ 2015-05-25 22:15 人生不酱油 阅读(270) 评论(0) 推荐(0) 编辑
摘要: No.147 Insertion Sorted ListSort a linked list using insertion sort.单链表排序:使用插入排序时间复杂度是排序算法的O(n^2),空间复杂度是O(1)难度:无他,把思路理顺,注意细节,并测试一下;另外头结点的巧妙应用,int最小表示方... 阅读全文
posted @ 2015-05-25 20:42 人生不酱油 阅读(130) 评论(0) 推荐(0) 编辑
摘要: No.21 Merge Two Sorted ListMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of th... 阅读全文
posted @ 2015-05-25 16:53 人生不酱油 阅读(130) 评论(0) 推荐(0) 编辑
摘要: No.88 Merge Sorted ArrayGiven two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:You may assume thatnums1has enough s... 阅读全文
posted @ 2015-05-25 16:35 人生不酱油 阅读(122) 评论(0) 推荐(0) 编辑
摘要: No.148 Sort ListSort a linked list inO(nlogn) time using constant space complexity.分析: 常量空间且O(nlogn)时间复杂度,单链表适合用归并排序,双向链表适合用快速排序 有一个问题是:若算上栈空间,空间复杂度... 阅读全文
posted @ 2015-05-25 16:22 人生不酱油 阅读(155) 评论(0) 推荐(0) 编辑
摘要: No.206 Reverse Linked ListReverse a singly linked list.单链表带头结点【leetcode判错】: 1 #include "stdafx.h" 2 3 struct ListNode 4 { 5 int val; 6 ListNo... 阅读全文
posted @ 2015-05-25 15:37 人生不酱油 阅读(125) 评论(0) 推荐(0) 编辑
摘要: No.49 AnagramsGiven an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.Tags:Hash TableString难点... 阅读全文
posted @ 2015-05-25 12:42 人生不酱油 阅读(498) 评论(0) 推荐(0) 编辑
摘要: No.50 Pow(x,n)Implement pow(x,n).Tags MathBinary Search编写函数pow(x,n)之前想的太过简单,只是分情况讨论,然后输出结果,但没有注意到效率,并且一些违法输入不知道如何表示。注意事项:对于整数处理,比较重要的注意点在于符号和处理越界的问题一般... 阅读全文
posted @ 2015-05-25 09:59 人生不酱油 阅读(440) 评论(0) 推荐(0) 编辑