Giter VIP home page Giter VIP logo

leetsol's Introduction

LeetSol

LeetSol is the compilation of solutions to the problems on LeetCode (https://leetcode.com/problemset/algorithms/). Most of the solutions are implemented using C++ but some are in C as well. All of these solutions have been tested with the LeetCode submission process.

The aim of this repository is to be the single point for checking solution to the problems. These solutions might not be perfect but cetrainly provide an alternative thought and way of implementation. Suggestions for improvement are highly appreciated.

Revisit Column has been marked with '*' or 'Y' in the cases where the proposed solution was not the best in runtime in comparison to other submissions.

Num Problem Tags Solution Revisit Notes
1 [Delete Node from Singly Linked List] (https://leetcode.com/problems/delete-node-in-a-linked-list/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/deleteNode.cpp) Y
2 [Delete nth node from end in the Linked List] (https://leetcode.com/problems/remove-nth-node-from-end-of-list/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/deleteNodeFromEnd.cpp) Y
3 [Find Intersection of Two Linked Lists] (https://leetcode.com/problems/intersection-of-two-linked-lists/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/list_intersection.cpp) Y
4 [Check if LinkedList is palindrome] (https://leetcode.com/problems/palindrome-linked-list/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/palindrome_llist.cpp) Y
5 [Remove duplicates from the List] (https://leetcode.com/problems/remove-duplicates-from-sorted-list/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/removeDuplicates.cpp) Y
6 [Check if Int is palindrom] (https://leetcode.com/problems/palindrome-number/) Miscellaneous, int [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/misc/int_palindrome.cpp) Y
7 [Strings : Is valid anagram] (https://leetcode.com/problems/valid-anagram/) Miscellaneous, string [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/misc/isAnagram.cpp) * Y
8 [Int : Is power of two] (https://leetcode.com/problems/power-of-two/) Miscellaneous, int [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/misc/powerOfTwo.cpp) Y
9 [Strings : Summary Ranges] (https://leetcode.com/problems/summary-ranges/) Miscellaneous, strings [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/misc/summaryRanges.cpp) Y
10 [Gas Station] (https://leetcode.com/problems/gas-station/) Array [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/circuitTraverse.cpp)
11 [Lowest common ancestor for Binary Search tree] (https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/bst_ancestor.cpp) Y
12 [Invert Binary tree - Chiral tree] (https://leetcode.com/problems/invert-binary-tree/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/invertTree.cpp) Y
13 [Path Sum] (https://leetcode.com/problems/path-sum/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/pathsum.cpp) Y
14 [Binary Tree Right view] (https://leetcode.com/problems/binary-tree-right-side-view/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/rightview.cpp) Y
15 [Merge two sorted linked lists] (https://leetcode.com/problems/merge-two-sorted-lists/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/mergSortedLists.cpp)
16 [Remove Nth element from the end of list] (https://leetcode.com/problems/remove-nth-node-from-end-of-list/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/removeNthFromEnd.cpp)
17 [Merge two sorted lists] (https://leetcode.com/problems/merge-two-sorted-lists/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/removeNthFromEnd.cpp)
18 [Insertion Sort : Linked List] (https://leetcode.com/problems/insertion-sort-list/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/insertionSortList.cpp)
19 [ Get cycle loop head ] (https://leetcode.com/problems/linked-list-cycle-ii/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/loopHead.cpp) Y
20 [ check if list has cycle ] (https://leetcode.com/problems/linked-list-cycle/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/hasCycle.cpp) Y
21 [ Reverse subset of List ] (https://leetcode.com/problems/reverse-linked-list-ii/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/reverseListSubset.cpp)
22 [ Keep only unique elements. Remove duplicate elements. ] (https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/keepUniqueList.cpp)
23 [ Swap adjacent nodes in Linked list ] (https://leetcode.com/problems/swap-nodes-in-pairs/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/swapNodes.cpp)
24 [ Reorder nodes in Linked List ] (https://leetcode.com/problems/reorder-list/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/reorderList.cpp)
25 [ Make a copy of Linked list with random pointer ] (https://leetcode.com/problems/copy-list-with-random-pointer/) Linked List [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/list/randomPtrList.cpp)
26 [ Balanced Binary Search Tree ] (https://leetcode.com/problems/balanced-binary-tree/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/isBalancedBTree.cpp)
27 [ Same Tree ] (https://leetcode.com/problems/same-tree/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/sameTree.cpp)
28 [ Binary Tree (inverted) Level Order Traversal ] (https://leetcode.com/problems/binary-tree-level-order-traversal-ii/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/levelOrderII.cpp)
29 [ Binary Tree Path sum II ] (https://leetcode.com/problems/path-sum-ii/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/PathSumII.cpp)
30 [ Binary Tree Level Order Traversal ] (https://leetcode.com/problems/binary-tree-level-order-traversal/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/BTreeLevelOrder.cpp)
31 [ Binary Tree Paths ] (https://leetcode.com/problems/binary-tree-paths/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/allPaths.cpp)
32 [ Max depth ] (https://leetcode.com/problems/maximum-depth-of-binary-tree/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/maxDepth.cpp)
33 [ Min depth ] (https://leetcode.com/problems/minimum-depth-of-binary-tree/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/minDepth.cpp)
34 [ Symmetric Tree ] (https://leetcode.com/problems/symmetric-tree/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/sameTree.cpp)
35 [ Binary Tree Pre-Order Traversal ] (https://leetcode.com/problems/binary-tree-preorder-traversal/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/preOrder.cpp)
36 [ Binary Search Tree Iterator ] (https://leetcode.com/problems/binary-search-tree-iterator/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/BSTIterator.cpp)
37 [ Happy Number ] (https://leetcode.com/problems/happy-number/) Math [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/math/HappyNumber.cpp)
38 [ Isomporphic Strings ] (https://leetcode.com/problems/isomorphic-strings/) String [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/strings/IsomorphicStrings.cpp)
39 [ Containes Duplicate ] (https://leetcode.com/problems/contains-duplicate/) Array [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/ContainsDuplicate.cpp)
40 [ Containes Duplicate II ] (https://leetcode.com/problems/contains-duplicate-ii/) Array [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/ContainsDuplicateII.cpp)
41 [ Ugly Number ] (https://leetcode.com/problems/ugly-number/) Math [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/math/UglyNumber.cpp)
42 [ Excel Sheet Column Number ] (https://leetcode.com/problems/excel-sheet-column-number/) String [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/strings/ExcelSheetColumnNumber.cpp)
43 [ Number of 1 bits ] (https://leetcode.com/problems/number-of-1-bits/) Bit Manipulation [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/misc/HammingWeight.cpp)
44 [ Missing Number ] (https://leetcode.com/problems/missing-number/) Math [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/math/missingNumber.cpp)
45 [ Count Primes ] (https://leetcode.com/problems/missing-number/) Math [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/math/missingNumber.cpp)
46 [ House Robber ] (https://leetcode.com/problems/house-robber/) Dynamic Programming [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/DP/HouseRobber.cpp)
47 [ Climbing Stairs ] (https://leetcode.com/problems/climbing-stairs/) Dynamic Programming [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/DP/ClimbingStairs.cpp)
48 [ Minimum Path Sum ] (https://leetcode.com/problems/minimum-path-sum/) Dynamic Programming [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/DP/MinPathSum.cpp)
49 [ Ugly Number II ] (https://leetcode.com/problems/ugly-number-ii/) Dynamic Programming [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/DP/UglyNumberII.cpp) *
50 [ Spiral Matrix ] (https://leetcode.com/problems/spiral-matrix/) Matrix [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/matrix/SpiralMatrix.cpp)
51 [ Single Number ] (https://leetcode.com/problems/single-number/) Array, Bit Manipluation [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/SingleNumber.cpp) *
52 [ Best time to Buy/Sell Stocks - II ] (https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/) Array, Greedy Programming [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/StockPrice.cpp)
53 [ Best time to Buy/Sell Stocks ] (https://leetcode.com/problems/best-time-to-buy-and-sell-stock/) Array, Dynamic Programming [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/StockPrice.cpp)
54 [ Product of Array except Self ] (https://leetcode.com/problems/product-of-array-except-self/) Array [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/productExceptSelf.cpp) *
55 [ Binary Tree Inorder traversal (non-recursive) ] (https://leetcode.com/problems/binary-tree-inorder-traversal/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/inOrder.cpp)
56 [ Populating Next Right pointers in Binary Tree ] (https://leetcode.com/problems/populating-next-right-pointers-in-each-node/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/nextRight.cpp) *
57 [ Unique Binary Search tree ] (https://leetcode.com/problems/unique-binary-search-trees/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/uniqueBSTCount.cpp)
58 [ Search Insert Position ] (https://leetcode.com/problems/search-insert-position/) Array, Binary Search [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/searchInsertPosition.cpp)
59 [ Single Number III ] (https://leetcode.com/problems/single-number-iii/) Bit Manipulation [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/SingleNumberIII.cpp) *
60 [ Unique Binary Search tree II ] (https://leetcode.com/problems/unique-binary-search-trees-ii/) Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/uniqueBSTGenerate.cpp) *
61 [ Convert Sorted Array to BST ] (https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/) Array, Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/sortedArrayToBST.cpp) * 20%
62 [ Maximum Subarray ] (https://leetcode.com/problems/maximum-subarray/) Array [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/maxSubArray.cpp)
63 [ Find minimum in Rotated Sorted Array ] (https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/) Array [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/findMinArray.cpp)
64 [ Unique Paths ] (https://leetcode.com/problems/unique-paths/) Array, Binary Tree [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/uniquePaths.cpp)
65 [ Kth smallest element in BST ] (https://leetcode.com/problems/kth-smallest-element-in-a-bst/) Binary Search Tree, DFS [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/btree/kthSmallestBST.cpp)
66 [ Nim Game ] (https://leetcode.com/problems/nim-game/) Dynamic Programming, Misc [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/misc/nimGame.cpp)
67 [ Add Digits ] (https://leetcode.com/problems/add-digits/) Misc, Recursion [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/misc/adddDigitByDigitalRoot.cpp)
68 [ Move Zeroes ] (https://leetcode.com/problems/move-zeroes/) Array [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/moveZeroes.cpp) * 20%
69 [ Majority Element ] (https://leetcode.com/problems/majority-element/) Array [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/majorityElement.cpp) * 40%
70 [ Valid Parenthesis ] (https://leetcode.com/problems/valid-parentheses/) Stack [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/Stack/ValidParenthesis.cpp)
71 [ Maximum Product of Word legths ] (https://leetcode.com/problems/maximum-product-of-word-lengths/) Strings [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/strings/maxProductWordLength.cpp) * [TIME LIMIT]
72 [ Fraction to Recurring Decimal ] (https://leetcode.com/problems/fraction-to-recurring-decimal/) Strings, Math [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/math/fractionToReccuringDecimal.cpp)
73 [ Permutations ] (https://leetcode.com/problems/permutations/) Recursion, Backtracking [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/misc/Permutations.cpp)
74 [ Rotate Array ] (https://leetcode.com/problems/rotate-array/) Array, Misc [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/rotateArray.cpp) <1% Y
75 [ Largest Increasing Sequnce ] Array, Misc [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/largestInterval.cpp) ?? Y
76 [ Most Frequent Item ] Array, Misc [Solution] (https://github.com/gitvipin/LeetSol/blob/master/src/array/mostFrequent.cpp) ?? Y

SQL Puzzles

Num Problem Tags Solution Revisit Notes
1 [Employees earning more than their Managers] (https://leetcode.com/problems/employees-earning-more-than-their-managers/) SQL Variables [Solution] (https://github.com/gitvipin/LeetSol/blob/master/db/sql/EmpMngrSalary.sql) Y
2 [Duplicate Emails] (https://leetcode.com/problems/duplicate-emails/) SQL, Self Join [Solution] (https://github.com/gitvipin/LeetSol/blob/master/db/sql/duplicateEmails.sql) Y
3 [Customers Who Never Order] (https://leetcode.com/problems/customers-who-never-order/) SQL, Self Join [Solution] (https://github.com/gitvipin/LeetSol/blob/master/db/sql/nonPayingCustomers.sql) Y

leetsol's People

Contributors

gitvipin 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.