自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

MissZhou要努力

路漫漫其修远兮,吾将上下而求索

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

原创 lintcode DP 总结

107.Word BreakFollowhttps://www.lintcode.com/problem/word-break/descriptionDescription中文EnglishGiven a string s and a dictionary of words dict, determine if s can be break into a space-separa...

2019-09-28 17:57:29 239

原创 lintcode 124. 最长连续序列[unordered_set]

https://www.lintcode.com/problem/longest-consecutive-sequence/description描述中文English给定一个未排序的整数数组,找出最长连续序列的长度。您在真实的面试中是否遇到过这个题?是题目纠错说明要求你的算法复杂度为O(n)样例样例 1输入 : [100, 4, 200, 1,...

2019-09-22 18:12:42 258

原创 lintcode87. 删除二叉查找树的节点 leetcode 450. Delete Node in a BST

Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.Basically, the deletion can be divided int...

2019-09-22 14:49:16 192

原创 lintcode 85. 在二叉查找树中插入节点

描述中文English给定一棵二叉查找树和一个新的树节点,将节点插入到树中。你需要保证该树仍然是一棵二叉查找树。保证不会出现重复的值您在真实的面试中是否遇到过这个题?是题目纠错样例样例 1: 输入: tree = {}, node= 1 输出: {1} 样例解释: 在空树中插入一个点,应该插入为根节点。 样例 2: 输入: tree...

2019-09-22 00:27:15 245

原创 lintcode 11. 二叉查找树中搜索区间

中序遍历一遍就好啦/** * Definition of TreeNode: * class TreeNode { * public: * int val; * TreeNode *left, *right; * TreeNode(int val) { * this->val = val; * this-&g...

2019-09-21 21:49:40 201

原创 lintcode 448. 二叉查找树的中序后继

本来以为 既然都是找后继 都是一样的结果 都!不!一!样!查找的时候怎么用val比较呢?考虑如果当前root的值比查找的 小于或等于:淘汰掉左子树就好要是需要找到左子树了,那么递归下去同样的方法,如果找不到,那么说明当前这个根节点是要找的class Solution {public: /* * @param root: The root of the B...

2019-09-21 20:59:15 230

原创 lintcode86. 二叉查找树迭代器

https://www.lintcode.com/problem/binary-search-tree-iterator/description看着这个题无比眼熟之前亚麻暑假实习manager问过我然而 那会是有父指针的这个题思路是什么呢?就变成了纯正的中序遍历非递归版的而且写法也有要求不能是while循环在外面的是要while current的然后就出了...

2019-09-21 18:03:41 171

原创 lintcode 95. 验证二叉查找树【剑指offer】

描述中文English给定一个二叉树,判断它是否是合法的二叉查找树(BST)一棵BST定义为:节点的左子树中的值要严格小于该节点的值。 节点的右子树中的值要严格大于该节点的值。 左右子树也必须是二叉查找树。 一个节点的树也是二叉查找树。您在真实的面试中是否遇到过这个题?是题目纠错样例样例 1:输入:{-1}输出:true解释:二叉树如下(仅有一个...

2019-09-21 01:16:22 203

原创 leetcode124. Binary Tree Maximum Path Sum

昨天晚上写了大概 今天晚上调了不到20分钟 做出了hard撒花就是dfs+dp的结合之前在微软面经看到过:)124.Binary Tree Maximum Path SumHard1992150FavoriteShareGiven anon-emptybinary tree, find the maximum path sum.For this proble...

2019-09-20 23:05:09 236

原创 lintcode 88LCA

https://lintcode.com/problem/lowest-common-ancestor-of-a-binary-tree/description描述中文English给定一棵二叉树,找到两个节点的最近公共父节点(LCA)。最近公共祖先是两个节点的公共的祖先节点且具有最大深度。假设给出的两个节点都在树中存在您在真实的面试中是否遇到过这个题?是题目...

2019-09-20 00:44:14 237

原创 剑指offer 二叉搜索树转双向链表

https://www.nowcoder.com/practice/947f6eb80d944a84850b0538bf0ec3a5?tpId=13&tqId=11179&tPage=2&rp=2&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking第二个参数必须传二级指针...

2019-09-13 01:20:35 235

原创 剑指offer【栈的压入 弹出序列】

https://www.nowcoder.com/practice/d77d11405cc7470d82554cb392585106?tpId=13&tqId=11174&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking个人觉得 还是我写...

2019-09-12 01:23:33 166

原创 剑指offer判断是否是子树

这么水的题居然搞了这么久。。https://www.nowcoder.com/practice/6e196c44c7004d15b1610b9afca8bd88?tpId=13&tqId=11170&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranki...

2019-09-12 00:23:54 247

原创 leetcode 116. Populating Next Right Pointers in Each Node & 117. Populating Next Right Pointers in E

You are given aperfect binary treewhereall leaves are on the same level, and every parent has two children. The binary tree has the following definition:struct Node { int val; Node *left; ...

2019-09-09 22:54:12 185

原创 leetcode 146. LRU Cache

https://leetcode.com/problems/lru-cache/submissions/Design and implement a data structure forLeast Recently Used (LRU) cache. It should support the following operations:getandput.get(key)- Ge...

2019-09-08 23:38:53 165

原创 leetcode 165. Compare Version Numbers

https://leetcode.com/problems/compare-version-numbers/Compare two version numbersversion1andversion2.Ifversion1>version2return1;ifversion1<version2return-1;otherwise return0....

2019-09-06 00:41:52 137

原创 leetcode 348. Design Tic-Tac-Toe【模拟】

348.Design Tic-Tac-ToeMedium44332FavoriteShareDesign a Tic-tac-toe game that is played between two players on anxngrid.You may assume the following rules:A move is guaranteed to be vali...

2019-09-05 00:56:37 368

原创 leetcode 277. Find the Celebrity【思维】

277.Find the CelebrityMedium71894FavoriteShareSuppose you are at a party withnpeople (labeled from0ton - 1) and among them, there may exist one celebrity. The definition of a celebrity is ...

2019-09-05 00:00:14 209

原创 leetcode 151. Reverse Words in a String【剑指offer】

https://leetcode.com/problems/reverse-words-in-a-string/151.Reverse Words in a StringMedium6362394FavoriteShareGiven an input string, reverse the string word by word.Example 1:Input: ...

2019-09-03 01:07:03 173

原创 leetcode138. Copy List with Random Pointer【剑指offer】

https://leetcode.com/problems/copy-list-with-random-pointer/A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Retur...

2019-09-03 00:09:40 228

原创 lintcode 168. 吹气球【记忆化搜索+区间dp】

168.吹气球中文English有n个气球,编号为0到n-1,每个气球都有一个分数,存在nums数组中。每次吹气球i可以得到的分数为nums[left] * nums[i] * nums[right],left和right分别表示i气球相邻的两个气球。当i气球被吹爆后,其左右两气球即为相邻。要求吹爆所有气球,得到最多的分数。样例样例 1:输入:[4, 1, 5, 10]...

2019-09-01 12:20:24 228

原创 lintcode 89. K数之和【背包】

89.K数之和中文English给定n个不同的正整数,整数k(k<=n)以及一个目标数字target。 在这n个数里面找出k个数,使得这k个数的和等于目标数字,求问有多少种方案?样例样例1输入:List = [1,2,3,4]k = 2target = 5输出: 2说明: 1 + 4 = 2 + 3 = 5样例2输入:...

2019-09-01 12:09:57 354

空空如也

空空如也

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

TA关注的人

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