GithubHelp home page GithubHelp logo

zetaraku / leetcode Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 796 KB

My LeetCode submissions written in C++, SQL, and TypeScript.

Home Page: https://leetcode.com/zetaraku/

C++ 88.29% Shell 0.41% Perl 1.00% TypeScript 10.30%
leetcode cpp sql typescript

leetcode's Introduction

leetcode

Generate README.md

My LeetCode submissions

  • Easy: 120 / 780
  • Medium: 94 / 1614
  • Hard: 9 / 683

Index

C++

No. Difficulty Title Code Time complexity Space complexity
1 Easy Two Sum 1-two-sum.cpp O(n) O(n)
2 Medium Add Two Numbers 2-add-two-numbers.cpp O(n1+n2) O(n1+n2)
3 Medium Longest Substring Without Repeating Characters 3-longest-substring-without-repeating-characters.cpp O(n) O(n)
5 Medium Longest Palindromic Substring 5-longest-palindromic-substring.cpp O(n^2) O(n)
6 Medium Zigzag Conversion 6-zigzag-conversion.cpp O(n) O(n)
8 Medium String to Integer (atoi) 8-string-to-integer-atoi.cpp O(n) O(1)
9 Easy Palindrome Number 9-palindrome-number.cpp O(1) O(1)
19 Medium Remove Nth Node From End of List 19-remove-nth-node-from-end-of-list.cpp O(n) O(1)
20 Easy Valid Parentheses 20-valid-parentheses.cpp O(n) O(n)
21 Easy Merge Two Sorted Lists 21-merge-two-sorted-lists.cpp O(min(n1, n2)) O(1)
22 Medium Generate Parentheses 22-generate-parentheses.cpp O(C(n)), where C(n) = the n-th Catalan number O(C(n)), where C(n) = the n-th Catalan number
23 Hard Merge k Sorted Lists 23-merge-k-sorted-lists.cpp O(n*log(k)) O(k)
28 Easy Find the Index of the First Occurrence in a String 28-find-the-index-of-the-first-occurrence-in-a-string.cpp O(m+n) O(m)
31 Medium Next Permutation 31-next-permutation.cpp O(n) O(1)
33 Medium Search in Rotated Sorted Array 33-search-in-rotated-sorted-array.cpp O(log(n)) O(log(n))
35 Easy Search Insert Position 35-search-insert-position.cpp O(log(n)) O(1)
39 Medium Combination Sum 39-combination-sum.cpp O(2^(n+t)*t) O(2^(n+t)*t)
46 Medium Permutations 46-permutations.cpp O(n*n!) O(n*n!)
48 Medium Rotate Image 48-rotate-image.cpp O(n^2) O(1)
49 Medium Group Anagrams 49-group-anagrams.cpp O(n*m*log(m)) O(n*m)
50 Medium Pow(x, n) 50-powx-n.cpp O(log(n)) O(log(n))
53 Medium Maximum Subarray 53-maximum-subarray.cpp O(n) O(1)
55 Medium Jump Game 55-jump-game.cpp O(n) O(1)
62 Medium Unique Paths 62-unique-paths.cpp O(m*n) O(m*n)
63 Medium Unique Paths II 63-unique-paths-ii.cpp O(m*n) O(m*n)
64 Medium Minimum Path Sum 64-minimum-path-sum.cpp O(m*n) O(m*n)
70 Easy Climbing Stairs 70-climbing-stairs.cpp O(n) O(n)
76 Hard Minimum Window Substring 76-minimum-window-substring.cpp O(m+n) O(m)
77 Medium Combinations 77-combinations.cpp O(k*C(n,k)) O(k*C(n,k))
78 Medium Subsets 78-subsets.cpp O(n*2^n) O(n*2^n)
82 Medium Remove Duplicates from Sorted List II 82-remove-duplicates-from-sorted-list-ii.cpp O(n) O(1)
83 Easy Remove Duplicates from Sorted List 83-remove-duplicates-from-sorted-list.cpp O(n) O(1)
88 Easy Merge Sorted Array 88-merge-sorted-array.cpp O(m+n) O(1)
91 Medium Decode Ways 91-decode-ways.cpp O(n) O(n)
94 Easy Binary Tree Inorder Traversal 94-binary-tree-inorder-traversal.cpp O(n) O(n)
95 Medium Unique Binary Search Trees II 95-unique-binary-search-trees-ii.cpp O(C(n)), where C(n) = the n-th Catalan number O(C(n))
98 Medium Validate Binary Search Tree 98-validate-binary-search-tree.cpp O(n) O(log(n))
102 Medium Binary Tree Level Order Traversal 102-binary-tree-level-order-traversal.cpp O(n) O(n)
103 Medium Binary Tree Zigzag Level Order Traversal 103-binary-tree-zigzag-level-order-traversal.cpp O(n) O(n)
104 Easy Maximum Depth of Binary Tree 104-maximum-depth-of-binary-tree.cpp O(n) O(log(n))
105 Medium Construct Binary Tree from Preorder and Inorder Traversal 105-construct-binary-tree-from-preorder-and-inorder-traversal.cpp O(n) O(n)
108 Easy Convert Sorted Array to Binary Search Tree 108-convert-sorted-array-to-binary-search-tree.cpp O(n) O(n)
111 Easy Minimum Depth of Binary Tree 111-minimum-depth-of-binary-tree.cpp O(n) O(log(n))
112 Easy Path Sum 112-path-sum.cpp O(n) O(n)
113 Medium Path Sum II 113-path-sum-ii.cpp O(n^2) O(n^2)
116 Medium Populating Next Right Pointers in Each Node 116-populating-next-right-pointers-in-each-node.cpp O(n) O(1)
118 Easy Pascal's Triangle 118-pascals-triangle.cpp O(n^2) O(n^2)
120 Medium Triangle 120-triangle.cpp O(n^2) O(n^2)
121 Easy Best Time to Buy and Sell Stock 121-best-time-to-buy-and-sell-stock.cpp O(n) O(1)
122 Medium Best Time to Buy and Sell Stock II 122-best-time-to-buy-and-sell-stock-ii.cpp O(n) O(1)
124 Hard Binary Tree Maximum Path Sum 124-binary-tree-maximum-path-sum.cpp O(n) O(n)
127 Hard Word Ladder 127-word-ladder.cpp O(m*n^2) O(m*n)
136 Easy Single Number 136-single-number.cpp O(n) O(1)
139 Medium Word Break 139-word-break.cpp O(m*n) O(n)
142 Medium Linked List Cycle II 142-linked-list-cycle-ii.cpp O(n) O(1)
144 Easy Binary Tree Preorder Traversal 144-binary-tree-preorder-traversal.cpp O(n) O(n)
145 Easy Binary Tree Postorder Traversal 145-binary-tree-postorder-traversal.cpp O(n) O(n)
146 Medium LRU Cache 146-lru-cache.cpp O(1) for { get(key), put(key, value) } O(n)
153 Medium Find Minimum in Rotated Sorted Array 153-find-minimum-in-rotated-sorted-array.cpp O(log(n)) O(log(n))
155 Medium Min Stack 155-min-stack.cpp O(1) for { push(x), pop(), top(), getMin() } O(n)
165 Medium Compare Version Numbers 165-compare-version-numbers.cpp O(n1+n2) O(1)
167 Medium Two Sum II - Input Array Is Sorted 167-two-sum-ii-input-array-is-sorted.cpp O(n) O(1)
174 Hard Dungeon Game 174-dungeon-game.cpp O(m*n) O(m*n)
189 Medium Rotate Array 189-rotate-array.cpp O(n) O(1)
190 Easy Reverse Bits 190-reverse-bits.cpp O(1) O(1)
191 Easy Number of 1 Bits 191-number-of-1-bits.cpp O(1) O(1)
198 Medium House Robber 198-house-robber.cpp O(n) O(n)
200 Medium Number of Islands 200-number-of-islands.cpp O(m*n) O(m*n)
201 Medium Bitwise AND of Numbers Range 201-bitwise-and-of-numbers-range.cpp O(log(n)) O(1)
202 Easy Happy Number 202-happy-number.cpp O(n) O(1)
205 Easy Isomorphic Strings 205-isomorphic-strings.cpp O(n) O(1)
206 Easy Reverse Linked List 206-reverse-linked-list.cpp O(n) O(1)
208 Medium Implement Trie (Prefix Tree) 208-implement-trie-prefix-tree.cpp O(n) for { insert(word), search(word), startsWith(prefix) } O(n)
213 Medium House Robber II 213-house-robber-ii.cpp O(n) O(n)
217 Easy Contains Duplicate 217-contains-duplicate.cpp O(n) O(n)
218 Hard The Skyline Problem 218-the-skyline-problem.cpp O(n*log(n)) O(n)
221 Medium Maximal Square 221-maximal-square.cpp O(m*n) O(m*n)
231 Easy Power of Two 231-power-of-two.cpp O(1) O(1)
234 Easy Palindrome Linked List 234-palindrome-linked-list.cpp O(n) O(n)
235 Medium Lowest Common Ancestor of a Binary Search Tree 235-lowest-common-ancestor-of-a-binary-search-tree.cpp O(h) O(h) or O(1) with tail-call optimization
238 Medium Product of Array Except Self 238-product-of-array-except-self.cpp O(n) O(n)
268 Easy Missing Number 268-missing-number.cpp O(n) O(1)
278 Easy First Bad Version 278-first-bad-version.cpp O(log(n)) O(1)
283 Easy Move Zeroes 283-move-zeroes.cpp O(n) O(1)
299 Medium Bulls and Cows 299-bulls-and-cows.cpp O(n) O(1)
300 Medium Longest Increasing Subsequence 300-longest-increasing-subsequence.cpp O(n*log(n)) O(n)
322 Medium Coin Change 322-coin-change.cpp O(K*M) O(K*M)
326 Easy Power of Three 326-power-of-three.cpp O(1) O(1)
342 Easy Power of Four 342-power-of-four.cpp O(1) O(1)
344 Easy Reverse String 344-reverse-string.cpp O(n) O(1)
347 Medium Top K Frequent Elements 347-top-k-frequent-elements.cpp O(n) O(n)
349 Easy Intersection of Two Arrays 349-intersection-of-two-arrays.cpp O(n1+n2) O(n1+n2)
350 Easy Intersection of Two Arrays II 350-intersection-of-two-arrays-ii.cpp O(n1+n2) O(n1+n2)
373 Medium Find K Pairs with Smallest Sums 373-find-k-pairs-with-smallest-sums.cpp O(k*log(k)) O(k)
383 Easy Ransom Note 383-ransom-note.cpp O(m+n) O(1)
387 Easy First Unique Character in a String 387-first-unique-character-in-a-string.cpp O(n) O(1)
392 Easy Is Subsequence 392-is-subsequence.cpp O(m+n) O(1)
394 Medium Decode String 394-decode-string.cpp O(n) O(n)
409 Easy Longest Palindrome 409-longest-palindrome.cpp O(n) O(1)
438 Medium Find All Anagrams in a String 438-find-all-anagrams-in-a-string.cpp O(m+n) O(m)
496 Easy Next Greater Element I 496-next-greater-element-i.cpp O(n1+n2) O(n1+n2)
503 Medium Next Greater Element II 503-next-greater-element-ii.cpp O(n) O(n)
509 Easy Fibonacci Number 509-fibonacci-number.cpp O(log(n)) O(log(n))
525 Medium Contiguous Array 525-contiguous-array.cpp O(n) O(n)
542 Medium 01 Matrix 542-01-matrix.cpp O(m*n) O(m*n)
543 Easy Diameter of Binary Tree 543-diameter-of-binary-tree.cpp O(n) O(n)
557 Easy Reverse Words in a String III 557-reverse-words-in-a-string-iii.cpp O(n) O(1)
560 Medium Subarray Sum Equals K 560-subarray-sum-equals-k.cpp O(n) O(n)
565 Medium Array Nesting 565-array-nesting.cpp O(n) O(n)
566 Easy Reshape the Matrix 566-reshape-the-matrix.cpp O(m*n) O(m*n)
567 Medium Permutation in String 567-permutation-in-string.cpp O(n1+n2) O(1)
587 Hard Erect the Fence 587-erect-the-fence.cpp O(n*log(n)) O(n)
589 Easy N-ary Tree Preorder Traversal 589-n-ary-tree-preorder-traversal.cpp O(n) O(n)
617 Easy Merge Two Binary Trees 617-merge-two-binary-trees.cpp O(n1+n2) O(n1+n2)
647 Medium Palindromic Substrings 647-palindromic-substrings.cpp O(n^2) O(1)
678 Medium Valid Parenthesis String 678-valid-parenthesis-string.cpp O(n) O(1)
692 Medium Top K Frequent Words 692-top-k-frequent-words.cpp O(n*log(k)) O(n)
695 Medium Max Area of Island 695-max-area-of-island.cpp O(m*n) O(m*n)
704 Easy Binary Search 704-binary-search.cpp O(log(n)) O(1)
724 Easy Find Pivot Index 724-find-pivot-index.cpp O(n) O(1)
733 Easy Flood Fill 733-flood-fill.cpp O(m*n) O(m*n)
739 Medium Daily Temperatures 739-daily-temperatures.cpp O(n) O(n)
746 Easy Min Cost Climbing Stairs 746-min-cost-climbing-stairs.cpp O(n) O(n)
764 Medium Largest Plus Sign 764-largest-plus-sign.cpp O(n^2) O(n^2)
784 Medium Letter Case Permutation 784-letter-case-permutation.cpp O(n*2^n) O(n*2^n)
844 Easy Backspace String Compare 844-backspace-string-compare.cpp O(n) O(1)
848 Medium Shifting Letters 848-shifting-letters.cpp O(n) O(n)
876 Easy Middle of the Linked List 876-middle-of-the-linked-list.cpp O(n) O(1)
899 Hard Orderly Queue 899-orderly-queue.cpp O(n^2) O(n)
917 Easy Reverse Only Letters 917-reverse-only-letters.cpp O(n) O(n)
929 Easy Unique Email Addresses 929-unique-email-addresses.cpp O(n) O(n)
977 Easy Squares of a Sorted Array 977-squares-of-a-sorted-array.cpp O(n) O(n)
978 Medium Longest Turbulent Subarray 978-longest-turbulent-subarray.cpp O(n) O(1)
994 Medium Rotting Oranges 994-rotting-oranges.cpp O(m*n) O(m*n)
1008 Medium Construct Binary Search Tree from Preorder Traversal 1008-construct-binary-search-tree-from-preorder-traversal.cpp O(n*log(n)) maybe? O(n)
1011 Medium Capacity To Ship Packages Within D Days 1011-capacity-to-ship-packages-within-d-days.cpp O(n*log(sum(W)-max(W))), where W = the weights of packages O(1)
1046 Easy Last Stone Weight 1046-last-stone-weight.cpp O(n*log(n)) O(n)
1137 Easy N-th Tribonacci Number 1137-n-th-tribonacci-number.cpp O(n) O(n)
1143 Medium Longest Common Subsequence 1143-longest-common-subsequence.cpp O(n1*n2) O(n1*n2)
1189 Easy Maximum Number of Balloons 1189-maximum-number-of-balloons.cpp O(n) O(1)
1426 Easy Counting Elements 1426-counting-elements.cpp O(n) O(n)
1427 Easy Perform String Shifts 1427-perform-string-shifts.cpp O(m+n) O(n)
1428 Medium Leftmost Column with at Least a One 1428-leftmost-column-with-at-least-a-one.cpp O(r+c) O(1)
1429 Medium First Unique Number 1429-first-unique-number.cpp O(1) for { showFirstUnique(), add(value) } O(n)
1430 Medium Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree 1430-check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree.cpp O(n) O(n)
1475 Easy Final Prices With a Special Discount in a Shop 1475-final-prices-with-a-special-discount-in-a-shop.cpp O(n) O(n)
1480 Easy Running Sum of 1d Array 1480-running-sum-of-1d-array.cpp O(n) O(n)
1629 Easy Slowest Key 1629-slowest-key.cpp O(n) O(1)
1944 Hard Number of Visible People in a Queue 1944-number-of-visible-people-in-a-queue.cpp O(n) O(n)
2487 Medium Remove Nodes From Linked List 2487-remove-nodes-from-linked-list.cpp O(n) O(1)

SQL

No. Difficulty Title Code Time complexity Space complexity
175 Easy Combine Two Tables 175-combine-two-tables.sql N/A N/A
176 Medium Second Highest Salary 176-second-highest-salary.sql N/A N/A
182 Easy Duplicate Emails 182-duplicate-emails.sql N/A N/A
183 Easy Customers Who Never Order 183-customers-who-never-order.sql N/A N/A
196 Easy Delete Duplicate Emails 196-delete-duplicate-emails.sql N/A N/A
197 Easy Rising Temperature 197-rising-temperature.sql N/A N/A
511 Easy Game Play Analysis I 511-game-play-analysis-i.sql N/A N/A
570 Medium Managers with at Least 5 Direct Reports 570-managers-with-at-least-5-direct-reports.sql N/A N/A
577 Easy Employee Bonus 577-employee-bonus.sql N/A N/A
584 Easy Find Customer Referee 584-find-customer-referee.sql N/A N/A
586 Easy Customer Placing the Largest Number of Orders 586-customer-placing-the-largest-number-of-orders.sql N/A N/A
595 Easy Big Countries 595-big-countries.sql N/A N/A
607 Easy Sales Person 607-sales-person.sql N/A N/A
608 Medium Tree Node 608-tree-node.sql N/A N/A
620 Easy Not Boring Movies 620-not-boring-movies.sql N/A N/A
627 Easy Swap Salary 627-swap-salary.sql N/A N/A
1050 Easy Actors and Directors Who Cooperated At Least Three Times 1050-actors-and-directors-who-cooperated-at-least-three-times.sql N/A N/A
1068 Easy Product Sales Analysis I 1068-product-sales-analysis-i.sql N/A N/A
1084 Easy Sales Analysis III 1084-sales-analysis-iii.sql N/A N/A
1141 Easy User Activity for the Past 30 Days I 1141-user-activity-for-the-past-30-days-i.sql N/A N/A
1148 Easy Article Views I 1148-article-views-i.sql N/A N/A
1158 Medium Market Analysis I 1158-market-analysis-i.sql N/A N/A
1280 Easy Students and Examinations 1280-students-and-examinations.sql N/A N/A
1378 Easy Replace Employee ID With The Unique Identifier 1378-replace-employee-id-with-the-unique-identifier.sql N/A N/A
1393 Medium Capital Gain/Loss 1393-capital-gainloss.sql N/A N/A
1407 Easy Top Travellers 1407-top-travellers.sql N/A N/A
1484 Easy Group Sold Products By The Date 1484-group-sold-products-by-the-date.sql N/A N/A
1527 Easy Patients With a Condition 1527-patients-with-a-condition.sql N/A N/A
1581 Easy Customer Who Visited but Did Not Make Any Transactions 1581-customer-who-visited-but-did-not-make-any-transactions.sql N/A N/A
1587 Easy Bank Account Summary II 1587-bank-account-summary-ii.sql N/A N/A
1661 Easy Average Time of Process per Machine 1661-average-time-of-process-per-machine.sql N/A N/A
1667 Easy Fix Names in a Table 1667-fix-names-in-a-table.sql N/A N/A
1683 Easy Invalid Tweets 1683-invalid-tweets.sql N/A N/A
1693 Easy Daily Leads and Partners 1693-daily-leads-and-partners.sql N/A N/A
1729 Easy Find Followers Count 1729-find-followers-count.sql N/A N/A
1741 Easy Find Total Time Spent by Each Employee 1741-find-total-time-spent-by-each-employee.sql N/A N/A
1757 Easy Recyclable and Low Fat Products 1757-recyclable-and-low-fat-products.sql N/A N/A
1795 Easy Rearrange Products Table 1795-rearrange-products-table.sql N/A N/A
1873 Easy Calculate Special Bonus 1873-calculate-special-bonus.sql N/A N/A
1890 Easy The Latest Login in 2020 1890-the-latest-login-in-2020.sql N/A N/A
1934 Medium Confirmation Rate 1934-confirmation-rate.sql N/A N/A
1965 Easy Employees With Missing Information 1965-employees-with-missing-information.sql N/A N/A

TypeScript

No. Difficulty Title Code Time complexity Space complexity
2619 Easy Array Prototype Last 2619-array-prototype-last.ts N/A N/A
2620 Easy Counter 2620-counter.ts N/A N/A
2621 Easy Sleep 2621-sleep.ts N/A N/A
2622 Medium Cache With Time Limit 2622-cache-with-time-limit.ts N/A N/A
2623 Medium Memoize 2623-memoize.ts N/A N/A
2625 Medium Flatten Deeply Nested Array 2625-flatten-deeply-nested-array.ts N/A N/A
2626 Easy Array Reduce Transformation 2626-array-reduce-transformation.ts N/A N/A
2627 Medium Debounce 2627-debounce.ts N/A N/A
2629 Easy Function Composition 2629-function-composition.ts N/A N/A
2631 Medium Group By 2631-group-by.ts N/A N/A
2634 Easy Filter Elements from Array 2634-filter-elements-from-array.ts N/A N/A
2635 Easy Apply Transform Over Each Element in Array 2635-apply-transform-over-each-element-in-array.ts N/A N/A
2637 Medium Promise Time Limit 2637-promise-time-limit.ts N/A N/A
2665 Easy Counter II 2665-counter-ii.ts N/A N/A
2666 Easy Allow One Function Call 2666-allow-one-function-call.ts N/A N/A
2667 Easy Create Hello World Function 2667-create-hello-world-function.ts N/A N/A
2677 Easy Chunk Array 2677-chunk-array.ts N/A N/A
2694 Medium Event Emitter 2694-event-emitter.ts N/A N/A
2695 Easy Array Wrapper 2695-array-wrapper.ts N/A N/A
2703 Easy Return Length of Arguments Passed 2703-return-length-of-arguments-passed.ts N/A N/A
2704 Easy To Be Or Not To Be 2704-to-be-or-not-to-be.ts N/A N/A
2705 Medium Compact Object 2705-compact-object.ts N/A N/A
2715 Easy Execute Cancellable Function With Delay 2715-execute-cancellable-function-with-delay.ts N/A N/A
2721 Medium Execute Asynchronous Functions in Parallel 2721-execute-asynchronous-functions-in-parallel.ts N/A N/A
2722 Medium Join Two Arrays by ID 2722-join-two-arrays-by-id.ts N/A N/A
2723 Easy Add Two Promises 2723-add-two-promises.ts N/A N/A
2724 Easy Sort By 2724-sort-by.ts N/A N/A
2725 Easy Interval Cancellation 2725-interval-cancellation.ts N/A N/A
2726 Easy Calculator with Method Chaining 2726-calculator-with-method-chaining.ts N/A N/A
2727 Easy Is Object Empty 2727-is-object-empty.ts N/A N/A

leetcode's People

Contributors

github-actions[bot] avatar zetaraku avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.