自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(22)
  • 收藏
  • 关注

原创 LC 127. Word Ladder 系列之一 BFS

Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that:Only one letter can be changed at a time...

2018-04-30 23:01:31 138

原创 LC 207 210 Course Schedule I / II BFS 有向图的拓扑排序,并应用于探测是否存在环

什么是拓扑排序?简而言之就是把有向图从复杂的立体的图的表示形式转化为线性的表示形式,对于图中所有的边(u, v),在拓扑排序后的结果中节点u的位置一定在节点v之前。拓扑排序可以用来解决先修课程、工程施工等常见的实际问题,将这种“要有A必须现有B”的关系抽象为图中A指向B的有向边,将整个问题的解决转化为寻找一条从开始点到结束点的路径。直接看题。207. Course ScheduleThere ar...

2018-04-30 16:27:11 175

原创 LC 198 213. House Robber I / II 动态规划

198. House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is th...

2018-04-30 16:10:29 154

原创 LC 216. Combination Sum III

前几天4.27回杭州,准备5月3号去上海梅龙镇广场办F-1面签。在家闲着无聊,代码状态又还不错,LC基本每天6,7道的进度,而且很多都是一次AC,一眨眼已经完成165道了。LC216很简单,很直接的回溯,但是之前写了一个Combination Sum II,感觉既然是一个系列的那就把这道也写一下吧。另外,我感觉我这样顺序做题有一个好处,就是在做到Combination Sum III的时候可以回看...

2018-04-30 15:55:52 134

原创 LC 86. Partition List 先组建两个子链表最后合并的思路

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of the...

2018-04-24 16:11:38 132

原创 Preorder and Postorder Traverse 基于栈的两种思路实现方法

to be written...

2018-04-24 16:09:09 477

原创 Remove Duplicates in Sorted Array (I /II)

26. Remove Duplicates from Sorted ArrayGiven a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for anoth...

2018-04-24 16:07:52 96

原创 LC 141,142 Linked List Cycle I / II 链表中的环

链表中的环是很经典的面试题,重要的是掌握链表类题目中快慢双指针的用法,不光可以用来解决环的探测,也可以解决其他的问题,例如查找链表中倒数第N个数,只要让fast比slow指针快N个节点,然后两个指针一起前进,当fast走到链表尽头,slow就指向倒数第N个节点(这道LC题前几天做到了,但是忘记是哪一道了)。LC 141 Linked List Cyclebool hasCycle(ListNode...

2018-04-24 13:10:29 124

原创 LC 136,137 Single Number I / II 数组中几乎所有数都出现了N次,找出唯一一个出现1次的数

LC 136 Single NumberGiven a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you impleme...

2018-04-24 11:38:30 183

原创 4月22日 刷题报告 LC128-132

128. Longest Consecutive SequenceGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.Your algorithm should run in O(n) complexity.Example:Input: [100, 4, ...

2018-04-23 12:48:50 164

原创 LC 125 Valid Palindrome 常见cctype库函数

非常简单的题目,判断一个给定的字符串是不是回文字符串,跳过字符串中非数字和字母的字符。具体描述如下:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we...

2018-04-21 17:14:14 149

原创 4月20日 刷题报告 LC108-114

今天下午没去实验室做毕设,一个人跑到图书馆刷题去了。气温微凉,外面下着点小雨,是我非常喜欢的天气。LC108,109 Convert Sorted Array / Sorted List to BSTLC108 将有序的数组转化为BST,LC109 将有序的单链表转化为BST。第一个比较简单,用二分和递归的方法,找到mid作为root,将两侧的子数组循环调用构造BST的递归函数。LC109的思路差...

2018-04-20 21:18:45 225

原创 LC 94,98,230 (栈实现的中序遍历三连)

题意:LC94 中序遍历BST,LC98 Validate BST,LC230 Kth Smallest element in BST。LC 94 中序遍历BST迭代的方法中序遍历BST,依赖栈实现,当前节点不为空时一直将左孩子压栈,当节点为空时说明左孩子为空,此时左子树遍历完毕,元素出栈得到父节点值,然后将右孩子压栈,循环往复。注意大循环的判断条件为while( root || ! st.emp...

2018-04-17 20:07:35 207

原创 LC 78. Subsets 求子集的递归和迭代解法

Given a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.For example,If nums = [1,2,3], a solution is:[ [3], [1...

2018-04-12 20:38:44 417

原创 LC 60. Permutation Sequence 排列系列之 求第k个排列

The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""312""321"

2018-04-08 21:39:11 138

原创 LC 77. Combinations 回溯 / 改进 求组合数C(n, k)

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]第一眼就感觉非...

2018-04-06 16:23:32 165

原创 LC 75. Sort Colors 双指针 对只含0、1、2的数组的排序,一次遍历

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0, 1...

2018-04-05 21:25:52 293

原创 LC31. Next Permutation 排列系列,数组操作

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible ord...

2018-04-05 14:51:16 250

原创 LC 48. Rotate Image 矩阵变换

You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the image in-place, which means you have to modify the input 2D matrix directl...

2018-04-03 23:07:01 131

原创 LC 43. Multiply Strings 大数乘法 / 字符串操作 / 细节:“000”要转化为“0”输出

Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2.Note:The length of both num1 and num2 is < 110.Both num1 and num2 contains only digits 0-9....

2018-04-03 20:43:15 152

原创 LC 42. Trapping Rain Water 双指针 求能收集的最多的水的体积

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], retu...

2018-04-03 19:42:13 417

原创 LC168 Excel Sheet Column Title 数学

Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB...

2018-04-02 20:08:53 222

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除