LeetCode Top100 Liked Questions】的更多相关文章

1. TwoSum https://www.cnblogs.com/zhacai/p/10429120.html  easy 2. Add Two Numbers https://www.cnblogs.com/zhacai/p/10429155.html  easy 15.3Sum https://www.cnblogs.com/zhacai/p/10579514.html medium set 20.Valid Parentheses https://www.cnblogs.com/zhac…
LeetCode Top Interview Questions https://leetcode.com/problemset/top-interview-questions/ # No. Title Acceptance Difficulty 1 1 Two Sum 38.80% Easy 2 2 Add Two Numbers 29.10% Medium 3 3 Longest Substring Without Repeating Characters 25.00% Medium 4 4…
两数相加 给出两个 非空 的链表用来表示两个非负的整数.其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字. 如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和. 您可以假设除了数字 0 之外,这两个数都不会以 0 开头. 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/add-two-numbers 著作权归领扣网络所有.商业转载请联系官方授权,非商业转载请注明出处. 思路分析: 设置一个…
字母异位词分组 给定一个字符串数组,将字母异位词组合在一起.字母异位词指字母相同,但排列不同的字符串. 思路: 一个map,将每个字符串字符进行记数,字符作为map的key,次数初始为零,以此来标识字符串 另外一个map是通过上一个map来作为key,添加字符串. 具体看代码.空间和效率都不咋地,23333. class Solution { public: vector<vector<string>> groupAnagrams(vector<string>&…
338. 比特位计数 题目描述: `给定一个非负整数 num.对于 0 ≤ i ≤ num 范围中的每个数字 i ,计算其二进制数中的 1 的数目并将它们作为数组返回. 示例 1: 输入: 2 输出: [0,1,1] 示例 2: 输入: 5 输出: [0,1,1,2,1,2] 思路描述: TIPs:别用暴力,超时- 1.先观察数字,首先奇数的二进制位最后一位一定为1,例子如3,5,7,所对应的二进制分别为11,101,0111, 2.而偶数的二进制位最后一位一定不为1,例子就不举了. 3.那么我…
题目: Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation. For example: Given "aacecaaa", return "aaacecaa…
Binary Search T(n) = T(n/2) + O(1)   =>    T(n) = O(lg n) proof: 如果能用iterable , 就用while loop, 可以防止用recursion的时候stack overflow( process in Linux is 8Mb), stack room is static for each process. (堆空间, heap room 是内存, 是动态的.)层数越多,存储更多中间/临时变量,最终超过系统配的stack空…
Pre: node 先,                      Inorder:   node in,           Postorder:   node 最后 PreOrder Inorder PostOrder node-> left -> right left -> node ->right left -> right ->node Recursive method 实际上代码是一样, 就是把ans.append(root.val) 放在如上表先, 中,…
Note: 后面数字n表明刷的第n + 1遍, 如果题目有**, 表明有待总结 Conclusion questions: [LeetCode] questions conclustion_BFS, DFS LeetCode questions conclustion_Path in Tree [LeetCode] questions conlusion_InOrder, PreOrder, PostOrder traversal [LeetCode] questions for Dynamic…
Questions: [LeetCode] 198. House Robber _Easy tag: Dynamic Programming [LeetCode] 221. Maximal Square _ Medium Tag: Dynamic Programming [LeetCode] 62. Unique Paths_ Medium tag: Dynamic Programming [LeetCode] 64. Minimum Path Sum_Medium tag: Dynamic P…
All LeetCode Questions List(Part of Answers, still updating) 题目汇总及部分答案(持续更新中) Leetcode problems classified by company 题目按公司分类(Last updated: October 2, 2017) .   Top Interview Questions # Title Difficulty Acceptance 1 Two Sum Medium 17.70% 2 Add Two N…
Facebook / Eng tech lead Dec 30, 2018  68 Comments   New Year Gift to every fellow time-constrained engineer out there looking for a job, here's a list of the best LeetCode questions that teach you core concepts and techniques for each category/type…
LeetCode面试常见100题( TOP 100 Liked Questions) 置顶 2018年07月16日 11:25:22 lanyu_01 阅读数 9704更多 分类专栏: 面试编程题真题合集 常见算法问题 LeetCode试题 LeetCode常见试题   版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/lanyu_01/article/details/81062232 这篇…
[LeetCode] Top 100 Liked Questions # Title Acceptance Difficulty 1 Two Sum 38.80% Easy 2 Add Two Numbers 29.10% Medium 3 Longest Substring Without Repeating Characters 25.00% Medium 4 Median of Two Sorted Arrays 23.70% Hard 5 Longest Palindromic Subs…
Path in Tree: [LeetCode] 112. Path Sum_Easy tag: DFS       input: root, target,   return True if exists sum(root-> leaf) == target else False       1 [LeetCode] 257. Binary Tree Paths_ Easy tag: DFS        input: root,   return all paths from root to…
BFS, DFS 的题目总结. Directed graph: Directed Graph Loop detection and if not have, path to print all path. BFS/DFS: (可以用BFS或者DFS的,主要还是遍历) [LeetCode] 733. Flood Fill_Easy tag: BFS     1 [LeetCode] 690. Employee Importance_Easy tag: BFS    1 [LeetCode] 529…
leetcode go语言版本,主要为了熟悉下语言 1. Two Sum 双指针版本, O(NlogN) func twoSum(nums []int, target int) []int { valResult := []int{} indexResult := []int{} i := 0 j := len(nums) - 1 temp := make([]int, len(nums)) copy(temp, nums) sort.Ints(temp) for i < j { if temp…
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example,Given nums = [0, 1, 3] return 2. Note:Your algorithm should run in linear runtime complexity. Could you implement it usi…
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. For example: Given nums = [1, 2, 1, 3, 2, 5], return [3, 5]. Note: The order…
因为在开始写这个博客之前,已经刷了100题了,所以现在还是有很多题目没有加进来,为了方便查找哪些没加进来,先列一个表可以比较清楚的查看,也方便给大家查找.如果有哪些题目的链接有错误,请大家留言和谅解,链多了会眼花.  # Title Category Difficulty  697  Degree of an Array  Algorithms  Easy  695  Max Area of Island  Algorithms  Easy  674  Longest Continuous In…
最近刷LeetCode比较频繁,就购买了官方的参考电子书 (CleanCodeHandbook),里面有题目的解析和范例源代码,可以省去非常多寻找免费经验分享内容和整理这些资料的时间.惊喜的是,里面的所有源代码都是用java语言写的. 接下来的一段时间里,我会将里面的大部分内容翻译成中文,再加上一些小y自己的解法和扩展内容,以博客的形式发在博客园.我想,这会是一件非常有趣的事情. 以下是翻译的前言部分,第1.4题以及其解析部分. 前言: 嗨,各位刷LeetCode的小伙伴们. 就像你们看到这本书…
Sept. 13, 2015 Spent more than a few hours to work on the leetcode problem, and my favorite blogs about this problems: 1. http://siddontang.gitbooks.io/leetcode-solution/content/tree/construct_binary_tree.html 2.http://blog.csdn.net/linhuanmars/artic…
Suppose you are at a party with n people (labeled from 0 to n - 1) and among them, there may exist one celebrity. The definition of a celebrity is that all the other n - 1people know him/her but he/she does not know any of them. Now you want to find…
August 2, 2015 在http://zzk.cnblogs.com/ 用"找一找", 花了几个小时, 找出比较好的Leetcode博客. Read the leetcode question and solutions: 1. Find lowest common ancestor in binary tree: blog of a facebook programmer working on leetcode questions: 递归版本:空间O(1),时间O(n) ht…
原题链接在这里:https://leetcode.com/problems/find-the-celebrity/ 题目: Suppose you are at a party with n people (labeled from 0 to n - 1) and among them, there may exist one celebrity. The definition of a celebrity is that all the other n - 1people know him/h…
In the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach or exceed 100 wins. What if we change the game so that players cannot re-use integers? For examp…
examination questions Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For example, Given [3,2,1,5,6,4] and k = 2, return 5. Note: You may assume k is always…
examination questions Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat…
examination questions Description: Count the number of prime numbers less than a non-negative number, n References: How Many Primes Are There? Sieve of Eratosthenes Please use the following function to solve the problem: int countPrimes(int n){ } 解题代…
写在前面 本题实际解题过程是 从 40秒 --> 24秒 -->1.5秒 --> 715ms --> 320ms --> 48ms --> 36ms --> 28ms 最后以28ms的运行速度告结, 有更好的解法或者减少算法复杂度的博友可以给我发消息也可以评论, 我们一起讨论. 第一次在leetcode解算法题,想来个开门红,先挑选一道简单的题目AC了再说.leetcode对每道题都有一个难度提示,分别是easy,medium,hard 于是在第一页中看到了几道标…