![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
Puya
人生不设限 没有不可能
展开
-
【LeetCode】寻找两个正序数组的中位数
4. 寻找两个正序数组的中位数难度困难3240收藏分享切换为英文关注反馈给定两个大小为 m 和 n 的正序(从小到大)数组nums1和nums2。请你找出这两个正序数组的中位数,并且要求算法的时间复杂度为O(log(m + n))。你可以假设nums1和nums2不会同时为空。示例 1:nums1 = [1, 3]nums2 = [2]则中位数是 2.0示例 2:nums1 = [1, 2]nums2 = [3, 4]则中位数是 (2 ...原创 2020-09-27 15:06:39 · 220 阅读 · 0 评论 -
【LeetCode】合并二叉树
617. 合并二叉树难度简单534收藏分享切换为英文关注反馈给定两个二叉树,想象当你将它们中的一个覆盖到另一个上时,两个二叉树的一些节点便会重叠。你需要将他们合并为一个新的二叉树。合并的规则是如果两个节点重叠,那么将他们的值相加作为节点合并后的新值,否则不为NULL 的节点将直接作为新二叉树的节点。示例1:输入: Tree 1 Tree 2 1 ..原创 2020-09-27 14:41:01 · 171 阅读 · 0 评论 -
【LeetCode】不同的二叉搜索树
96. 不同的二叉搜索树难度中等765收藏分享切换为英文关注反馈给定一个整数n,求以1 ...n为节点组成的二叉搜索树有多少种?示例:输入: 3输出: 5解释:给定 n = 3, 一共有 5 种不同结构的二叉搜索树: 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / \ ...原创 2020-08-19 22:54:29 · 223 阅读 · 0 评论 -
【LeetCode】 reverse-linked-list-ii
时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32M,其他语言64M热度指数:20029本题知识点:链表leetcode算法知识视频讲解题目描述将一个链表m位置到n位置之间的区间反转,要求使用原地算法,并且在一次扫描之内完成反转。例如:给出的链表为1->2->3->4->5->NULL,m= 2 ,n= 4,返回1->4->3->2->5->NULL.注意:给出的m,n满足以下条件...原创 2020-07-31 15:19:36 · 149 阅读 · 0 评论 -
【LeetCode】word-break-ii
时间限制:1秒空间限制:32768K热度指数:35240本题知识点:动态规划leetcode算法知识视频讲解题目描述Given a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary...原创 2019-04-14 16:36:35 · 330 阅读 · 0 评论 -
【LeetCode】merge-two-sorted-lists
merge-two-sorted-lists时间限制:1秒 空间限制:32768K 热度指数:8819本题知识点: 链表 leetcode算法知识视频讲解 题目描述Merge two sorted linked lists and return it as a new list. The new list should be made by splicing togeth...原创 2019-03-15 16:24:11 · 180 阅读 · 0 评论 -
【LeetCode】merge-sorted-array
时间限制:1秒 空间限制:32768K 热度指数:8547本题知识点: 数组 leetcode算法知识视频讲解 题目描述Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space to hol...原创 2019-03-15 16:14:52 · 163 阅读 · 0 评论 -
【LeetCode】3sum
题目描述 Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,...原创 2018-12-30 16:06:01 · 773 阅读 · 0 评论 -
【LeetCode】two-sum
题目描述 Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the targ...原创 2018-12-30 15:15:21 · 231 阅读 · 0 评论 -
【LeetCode】length-of-last-word
Given a string s consists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is define...原创 2018-12-28 13:28:56 · 172 阅读 · 0 评论 -
【LeetCode】combinations
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-12-28 12:50:34 · 124 阅读 · 0 评论 -
【LeetCode】sum-root-to-leaf-numbers
Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which represents the number123.Find the total sum...原创 2018-12-27 16:29:14 · 178 阅读 · 0 评论 -
【leetcode】same-tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value. /** * Def...原创 2018-12-27 15:27:48 · 116 阅读 · 0 评论 -
【LeetCode】maximum-depth-of-binary-tree
[编程题] maximum-depth-of-binary-tree时间限制:1秒空间限制:32768K Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to th...原创 2018-12-26 20:20:48 · 147 阅读 · 0 评论 -
【leetcode】Single Number
[编程题] single-number时间限制:1秒空间限制:32768K Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexi...原创 2018-12-26 14:41:21 · 148 阅读 · 0 评论