All Projects → hqztrue → Leetcodesolutions

hqztrue / Leetcodesolutions

Theoretical solutions for LeetCode problems.

Projects that are alternatives of or similar to Leetcodesolutions

Algorithms Leetcode Javascript
Algorithms resolution in Javascript. Leetcode - Geeksforgeeks - Careercup
Stars: ✭ 157 (-23.41%)
Mutual labels:  algorithms, data-structures, leetcode, leetcode-solutions
Leetcode 101
LeetCode 101:和你一起你轻松刷题(C++)
Stars: ✭ 5,327 (+2498.54%)
Mutual labels:  algorithms, data-structures, leetcode, leetcode-solutions
Leetcode In Swift
My solutions to LeetCode problems written in Swift
Stars: ✭ 150 (-26.83%)
Mutual labels:  algorithms, data-structures, leetcode, leetcode-solutions
Datastructures Algorithms
The best library for implementation of all Data Structures and Algorithms - Trees + Graph Algorithms too!
Stars: ✭ 2,105 (+926.83%)
Mutual labels:  algorithms, data-structures, leetcode, leetcode-solutions
Leetcode
👏🏻 leetcode solutions for Humans™
Stars: ✭ 1,129 (+450.73%)
Mutual labels:  algorithms, leetcode, leetcode-solutions
Leetcode Java Solutions
Solutions to LeetCode Online Judge problems in Java
Stars: ✭ 194 (-5.37%)
Mutual labels:  algorithms, leetcode, leetcode-solutions
Competitive Programming
Hello Programmers 💻 , A one-stop Destination✏️✏️ for all your Competitive Programming Resources.📗📕 Refer CONTRIBUTING.md for contributions
Stars: ✭ 113 (-44.88%)
Mutual labels:  algorithms, data-structures, leetcode
Leetcode
😖 😕 😃LeetCode问题解题思路。
Stars: ✭ 130 (-36.59%)
Mutual labels:  algorithms, data-structures, leetcode
Algorithm study
algorithms and data structures for coding contest (designed for 'copy & paste')
Stars: ✭ 33 (-83.9%)
Mutual labels:  algorithms, data-structures, leetcode-solutions
Competitiveprogrammingquestionbank
This repository contains all the popular competitive programming and DSA questions with solutions.
Stars: ✭ 122 (-40.49%)
Mutual labels:  algorithms, data-structures, leetcode
Leetcode Algorithm
分类整理leetcode算法题解,代码语言采用c++与python实现
Stars: ✭ 184 (-10.24%)
Mutual labels:  algorithms, data-structures, leetcode
Leetcode Python
LeetCode solutions in Python2. LeetCode题解 in Python2。
Stars: ✭ 182 (-11.22%)
Mutual labels:  algorithms, leetcode, leetcode-solutions
Awesome Java Leetcode
👑 LeetCode of algorithms with java solution(updating).
Stars: ✭ 8,297 (+3947.32%)
Mutual labels:  algorithms, leetcode, leetcode-solutions
Leetcode
LeetCode Solutions: A Record of My Problem Solving Journey.( leetcode题解,记录自己的leetcode解题之路。)
Stars: ✭ 45,650 (+22168.29%)
Mutual labels:  data-structures, leetcode, leetcode-solutions
Leetcode Python
Leetcode Python Solution and Explanation. Also a Guide to Prepare for Software Engineer Interview.
Stars: ✭ 1,088 (+430.73%)
Mutual labels:  algorithms, data-structures, leetcode
Leetcode
✏️ 算法相关知识储备 LeetCode with Python and JavaScript 📚
Stars: ✭ 1,713 (+735.61%)
Mutual labels:  leetcode, leetcode-solutions, data-structures
Leetcode Patterns
A curated list of leetcode questions grouped by their common patterns
Stars: ✭ 3,750 (+1729.27%)
Mutual labels:  algorithms, data-structures, leetcode
Coding Problems
Solutions for various coding/algorithmic problems and many useful resources for learning algorithms and data structures
Stars: ✭ 2,221 (+983.41%)
Mutual labels:  algorithms, data-structures, leetcode
Leetcode
Provide all my solutions and explanations in Chinese for all the Leetcode coding problems.
Stars: ✭ 5,619 (+2640.98%)
Mutual labels:  data-structures, leetcode, leetcode-solutions
Hello Algorithm
🌍 针对小白的算法训练 | 包括四部分:①.算法基础 ②.力扣图解 ③.大厂面经 ④.CS_汇总 | 附:1、千本开源电子书 2、百张技术思维导图(项目花了上百小时,希望可以点 star 支持,🌹感谢~)
Stars: ✭ 29,372 (+14227.8%)
Mutual labels:  algorithms, leetcode, leetcode-solutions

LeetCode

Introduction

Here are theoretical solutions for some interesting LeetCode problems, aiming for the best running time. The author is a TCS student who no longer frequently write codes, so if you are looking for code implementations... sorry, this might be the wrong place. There's one exception though: if an algorithm with good theoretical guarantee is also practical enough to strictly beat 100% of the submissions, I will consider to implement it. See figs/ for a list of them.

p.s. If one doesn't like my coding style, he can use the following code formatting tools: https://codebeautify.org/cpp-formatter-beautifier, http://format.krzaq.cc/, or https://github.com/akof1314/CoolFormat

For most problems we consider here, the only thing we want to optimize is the running time. Randomization is usually allowed. Sometimes we will optimize on the space complexity as well. Lower bound will be provided, if the optimality of our algorithm is not obvious. If the main source of hardness of a problem is its coding complexity rather than the algorithm (e.g. simulation problems), we will skip the solution here.

Notations

In some problems we will use the word-RAM model, where the assumption is each word has w bits and can store integers up to size W=2^w. In practice (i.e. 32-bit machines), w=32 and W=2^32. We assume the word length is w=\Omega(\log n), and the following basic word operations in the multiplicative instruction set can be executed in O(1): +, -, (*), &, |, ^, ~, <<, >>. By setting w'=\delta_0\log n for a sufficiently small constant \delta_0>0, we can simulate nonstandard word operations on w'-bit words in O(1) time by table lookup, with n^{O(\delta_0)}=o(n) preprocessing time. Theoretically speaking, you can always implement algorithms in the word-RAM model in codes.

For string, let |\Sigma| denote the alphabet size (i.e. |\Sigma|=26 for lowercase letters), and we usually assume |\Sigma| is much smaller than n. In some cases, we further make the (non-theory) assumption that |\Sigma|<=w (since 26<32). If the input is a set of strings, we will use L to denote the total length of them, and n is the number of strings. If the input is a single string, we use n to denote its length.

For trees, let h denote the height.

For graphs, let n denote the number of vertices and m denote the number of edges.

If the input is an n*m matrix, we sometimes use a single parameter n to denote max(n,m) for simplicity.

For space complexity, we use the definition which is in analogy to the following: for a TM with a (read-only) input tape, an output tape and work tapes, only the number of memory cells on work tapes counts. Here we assume the input is read-only, and for space complexity, we only count the number of memory cells on which we write. Note that this is different from the (relatively weaker) LeetCode definition, which usually allows in-place modifications to the memory cells containing the inputs. We call that definition "additional space complexity".

Unsolved Problems

Here are a list of problems for which I don't know the current best algorithm. If a problem is open but the algorithm I provide here is (almost) the current best, it is viewed as "solved" and therefore not listed below. Some NP-hard problems are also not included.

open_problems.txt

Miscellaneous Topics

Get your hands dirty: miscellaneous_topics.pdf

Stargazers over time

Stargazers over time

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].