随笔分类 - 刷题进行时
摘要:No.67 Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100". 与No.2 Add Two Numbers的思路非常相似,...
阅读全文
摘要:No.2 Add Two NumbersYou are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nod...
阅读全文
摘要:No.165 Compare Version NumbersCompare two version numbersversion1andversion2.Ifversion1>version2return 1, ifversion1 version2 return 1, if version1 d...
阅读全文
摘要:No.68 Text JustificationGiven an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right...
阅读全文
摘要:No.29 Divide Two IntegersDivide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.Tags:MathBinary...
阅读全文
摘要:No.7 Reverse IntegerReverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321反转数字:将对10整除和取余的结果逆置即可难点即细节:溢出。符号疑问:溢出的,怎么处理...
阅读全文
摘要:No.166 Fraction to Recurring DecimalGiven two integers representing the numerator and denominator of a fraction, return the fraction in string format....
阅读全文
摘要:No.65 Valid NumberValidate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>trueNote:It is intended fo...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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:考虑不周,一条直线上的点会重复计数,但没找到解...
阅读全文
摘要:No.147 Insertion Sorted ListSort a linked list using insertion sort.单链表排序:使用插入排序时间复杂度是排序算法的O(n^2),空间复杂度是O(1)难度:无他,把思路理顺,注意细节,并测试一下;另外头结点的巧妙应用,int最小表示方...
阅读全文
摘要: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...
阅读全文
摘要:No.88 Merge Sorted ArrayGiven two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:You may assume thatnums1has enough s...
阅读全文
摘要:No.148 Sort ListSort a linked list inO(nlogn) time using constant space complexity.分析: 常量空间且O(nlogn)时间复杂度,单链表适合用归并排序,双向链表适合用快速排序 有一个问题是:若算上栈空间,空间复杂度...
阅读全文
摘要:No.206 Reverse Linked ListReverse a singly linked list.单链表带头结点【leetcode判错】: 1 #include "stdafx.h" 2 3 struct ListNode 4 { 5 int val; 6 ListNo...
阅读全文
摘要: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难点...
阅读全文
摘要:No.50 Pow(x,n)Implement pow(x,n).Tags MathBinary Search编写函数pow(x,n)之前想的太过简单,只是分情况讨论,然后输出结果,但没有注意到效率,并且一些违法输入不知道如何表示。注意事项:对于整数处理,比较重要的注意点在于符号和处理越界的问题一般...
阅读全文
摘要:No.146 LRU CacheDesign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(ke...
阅读全文
摘要:No.35 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 ...
阅读全文

浙公网安备 33010602011771号