All LeetCode Questions List 题目汇总 Sorted by frequency of problems that appear in real interviews. Last updated: October 2, 2017Google (214)534 Design TinyURL388 Longest Absolute File Path683 K Empty Slots340 Longest Substring with At Most K Distinct C…
LinkedIn(39) 1 Two Sum 23.0% Easy 21 Merge Two Sorted Lists 35.4% Easy 23 Merge k Sorted Lists 23.3% Hard 33 Search in Rotated Sorted Array 30.2% Hard 34 Search for a Range 29.1% Medium 46 Permutations 35.7% Medium 47 Permutations II 28.0% Medium 50…
LeetCode: Palindrome 回文相关题目汇总 LeetCode: Palindrome Partitioning 解题报告 LeetCode: Palindrome Partitioning II 解题报告 Leetcode:[DP]Longest Palindromic Substring 解题报告 LeetCode: Valid Palindrome 解题报告…
1.set没有back()函数,今天想到用这个,才发现没有. 2. tuple的initialize_list construct好像不能使用,其实之前没使用过tuple,都是pair,复杂一点的自己写struct或者class,然后写比较的方法.不能用的原因是explicit关键字的限制,其实之前对explicit的关键字不是很了解,现在知道是什么了.不能进行隐式转换,只能显式调用. 3. LeetCode 499. The Maze II 没有权限,不能看.从别处看了下题目,我不会做!感觉抽…
题目描述: 给定一个包含红色.白色和蓝色,一共 n 个元素的数组,原地对它们进行排序,使得相同颜色的元素相邻,并按照红色.白色.蓝色顺序排列. 此题中,我们使用整数 0. 1 和 2 分别表示红色.白色和蓝色. 注意:不能使用代码库中的排序函数来解决这道题. 示例: 输入: [2,0,2,1,1,0] 输出: [0,0,1,1,2,2] 进阶:一个直观的解决方案是使用计数排序的两趟扫描算法. 首先,迭代计算出0.1 和 2 元素的个数, 然后按照0.1.2的排序,重写当前数组. 你能想出一个仅使…
/** * Find the contiguous subarray within an array (containing at least one number) * which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2,1] has the largest sum = 6. click to show more prac…
这次接触到记忆化DFS,不过还需要多加练习 113. 路径总和 II - (根到叶子结点相关信息记录) """ 思路: 本题 = 根到叶子结点的路径记录 + 根到叶子结点的值记录 """ class Solution: def pathSum(self, root: TreeNode, sum: int) -> List[List[int]]: res = [] def DFS(root, s, tmp): if not root: ret…
Coding everyday. ^_^ 1. Two Sum 重点知识:指针可以存储数值,通过 malloc 新建数组 int* returnSize:Size of the return array. Store the value in a pointer, say 2.*returnSize = 2 My solution: /** * Note: The returned array must be malloced, assume caller calls free(). */ in…