Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aa8y/leetcode

Leetcode problems solved in different languages
https://github.com/aa8y/leetcode

java leetcode node-js scala

Last synced: 22 days ago
JSON representation

Leetcode problems solved in different languages

Awesome Lists containing this project

README

        

# Solutions to [LeetCode problems](https://leetcode.com/problemset/all/)

[![Build Status](https://travis-ci.org/aa8y/leetcode.svg?branch=master)](https://travis-ci.org/aa8y/leetcode)

## Langauages

The solutions are in three languages,
* [Java](https://www.java.com)
* [Node.js](https://nodejs.org/)
* [Scala](https://www.scala-lang.org/)

More might get added in the future as I learn new languages.

## Legend

| Acronym | Description |
|:--------|:------------|
| NA | Denotes the metric is Not Available. |
| TODO | This is an interesting question which I intend to solve in the future. |
| WIP | Solution hasn't been accepted because it either hasn't passed all test cases or has thrown an exception. Tests for these would be ignored in the CI build. |

## Solutions by language

| # | Problem | Difficulty | Status (w/ Source) | Runtime (ms) | Memory Usage (MB) |
|-----:|:---------|:--------------------------:|:------------------:|-----------------------------:|-----------------------------:|
| 1 | [Two Sum](https://leetcode.com/problems/two-sum/submissions/) | Easy | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/TwoSumBruteForce.java) | 44 | 39.5 |
| | | | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/TwoSumLinearTime.java) | 4 | 38.4 |
| 11 | [Container With Most Water](https://leetcode.com/problems/container-with-most-water/) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/ContainerWithMostWater.java) | 4 | 40.7 |
| 13 | [Roman to Integer](https://leetcode.com/problems/roman-to-integer/) | Easy | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/RomanToInteger.java) / [Scala](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/RomanToInteger.scala) | 98 / 428 | 46.2 / 53.6 |
| 14 | [Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix/) | Easy | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/LongestCommonPrefixQuadratic.java) | 7 | 39 |
| | | | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/LongestCommonPrefixTrie.java) | 9 | 38.9 |
| | | | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/LongestCommonPrefixLinear.java) | 4 | 38.2 |
| 15 | [3Sum](https://leetcode.com/problems/3sum/) | Medium | [Scala](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/ThreeSum.scala) | 8708 | 89.4 |
| 20 | [Valid Parentheses](https://leetcode.com/problems/valid-parentheses/) | Easy | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/ValidParentheses.java) | 5 | 37.1 |
| 48 | [Rotate Image](https://leetcode.com/problems/rotate-image/) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/RotateImage.java) | 1 | 37.3 |
| 55 | [Jump Game](https://leetcode.com/problems/jump-game/) | Medium | [WIP](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/JumpGame.java) | NA | NA |
| 62 | [Unique Paths](https://leetcode.com/problems/unique-paths/description/) | Medium | [Scala](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/UniquePaths.scala) | 296 | 40.9 |
| 70 | [Climbing Stairs](https://leetcode.com/problems/climbing-stairs/) | Easy | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/ClimbingStairs.java) | 2 | 36.5 |
| 76 | [Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring/) | Hard | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/MinimumWindowSubstring.java) / [Scala](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/MinimumWindowSubstring.scala)| 253 / NA | 39.5 / NA |
| 79 | [Word Search](https://leetcode.com/problems/word-search/) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/WordSearch.java) | 79 | 62.6 |
| 88 | [Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array/description/) | Easy | [Node.js](https://github.com/aa8y/leetcode/blob/master/node.js/src/main/mergeSortedArray.js) | NA | NA |
| 92 | [Reverse Linked List II](https://leetcode.com/problems/reverse-linked-list-ii/description/) | Medium | [WIP](https://github.com/aa8y/leetcode/blob/master/node.js/src/main/reverseLinkedList2.js) | NA | NA |
| 94 | [Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal/description/) | Medium | [Node.js](https://github.com/aa8y/leetcode/blob/master/node.js/src/main/binaryTreeInOrderTraversal.js) | NA | NA |
| 102 | [Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/description/) | Medium | [Node.js](https://github.com/aa8y/leetcode/blob/master/node.js/src/main/binaryTreeLevelOrderTraversal.js) | NA | NA |
| 108 | [Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/) | Easy | TODO | NA | NA |
| 135 | [Candy](https://leetcode.com/problems/candy/) | Hard | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/Candy.java) | 9148 | 74.2 |
| 190 | [Reverse Bits](https://leetcode.com/problems/reverse-bits/) | Easy | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/ReverseBitsIterative.java) | 1 | 28 |
| | | | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/ReverseBitsRecursive.java) | 1 | 28 |
| 191 | [Number of 1 Bits](https://leetcode.com/problems/number-of-1-bits/) | Easy | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/NumberOf1BitsIterative.java) | 0 | 34.8 |
| | | | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/NumberOf1BitsRecursive.java) | 0 | 34.9 |
| 200 | [Number of Islands](https://leetcode.com/problems/number-of-islands/) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/NumberOfIslandsDfs.java) | 5 | 40.9 |
| 206 | [Reverse Linked List](https://leetcode.com/problems/reverse-linked-list/) | Easy | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/ReverseLinkedListIterative.java) / [Node.js](https://github.com/aa8y/leetcode/blob/master/node.js/src/main/reverseLinkedList.js) | 0 / NA | 37.6 / NA |
| 207 | [Course Schedule](https://leetcode.com/problems/course-schedule/) | Medium | [WIP](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/CourseSchedule.scala) | NA | NA |
| | | | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/ReverseLinkedListRecursive.java) | 0 | 37.6 |
| 208 | [Implement Trie (Prefix Tree)](https://leetcode.com/problems/implement-trie-prefix-tree/) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/ImplementTriePrefixTree.java) | 92 | 59.4 |
| 240 | [Search a 2D Matrix II](https://leetcode.com/problems/search-a-2d-matrix-ii/) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/SearchA2DMatrix2.java) | 24 | 50 |
| 322 | [Coin Change](https://leetcode.com/problems/coin-change/) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/CoinChange.java) | 152 | 42.5 |
| 338 | [Counting Bits](https://leetcode.com/problems/counting-bits/) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/CountingBitsQuadratic.java) | 2 | 39.3 |
| | | | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/CountingBitsLinear.java) | 1 | 39.6 |
| 344 | [Reverse String](https://leetcode.com/problems/reverse-string/) | Easy | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/ReverseString.java) | 12 | 48.4 |
| 371 | [Sum of Two Integers](https://leetcode.com/problems/sum-of-two-integers/) | Easy | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/SumOfTwoIntegers.java) | 0 | 34.5 |
| 417 | [Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow/) | Medium | [WIP](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/PacificAtlanticWaterFlow.java) | NA | NA |
| 538 | [Convert BST to Greater Tree](https://leetcode.com/problems/convert-bst-to-greater-tree/description/) | Easy | [Node.js](https://github.com/aa8y/leetcode/blob/master/node.js/src/main/bstToGreaterTree.js) | NA | NA |
| 704 | [Binary Search](https://leetcode.com/problems/binary-search/) | Easy | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/BinarySearch.java) | 2 | 40.7 |
| 722 | [Remove Comments](https://leetcode.com/problems/remove-comments/) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/RemoveComments.java) | 266 | 29 |
| 745 | [Prefix and Suffix Search](https://leetcode.com/problems/prefix-and-suffix-search/description/) | Hard | [WIP](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/PrefixAndSuffixSearch.scala) | NA | NA |
| 749 | [Shortest Completing Word](https://leetcode.com/problems/shortest-completing-word/description/) | Medium | [Scala](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/ShortestCompletingWord.scala) | 540 | 53.6 |
| 762 | [Prime Number of Set Bits in Binary Representation](https://leetcode.com/contest/weekly-contest-67/problems/prime-number-of-set-bits-in-binary-representation/) | Easy | [Scala](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/PrimeNumberOfSetBitsInBinaryRepresentation.scala) | 640 | 48.3 |
| 763 | [Partition Labels](https://leetcode.com/contest/weekly-contest-67/problems/partition-labels/) | Medium | [Scala](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/PartitionLabels.scala) | 396 | 48.1 |
| 764 | [Largest Plus Sign](https://leetcode.com/contest/weekly-contest-67/problems/largest-plus-sign/) | Medium | [WIP](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/LargestPlusSign.scala) | NA | NA |
| 765 | [Couples Holding Hands](https://leetcode.com/contest/weekly-contest-67/problems/couples-holding-hands/) | Hard | [WIP](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/CouplesHoldingHands.scala) | NA | NA |
| 933 | [Number of Recent Calls](https://leetcode.com/contest/weekly-contest-109/problems/number-of-recent-calls/) | Easy | [Scala](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/NumberOfRecentCalls.scala) | 1428 | 95.9 |
| 934 | [Shortest Bridge](https://leetcode.com/contest/weekly-contest-109/problems/shortest-bridge/) | Medium | [WIP](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/ShortestBridge.scala) | NA | NA |
| 936 | [Stamping The Sequence](https://leetcode.com/contest/weekly-contest-109/problems/stamping-the-sequence/) | Hard | [WIP](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/StampingTheSequence.scala) | NA | NA |
| 937 | [Reorder Log Files](https://leetcode.com/contest/weekly-contest-110/problems/reorder-log-files/) | Easy | [Scala](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/ReorderLogFiles.scala) | 472 | 51.5 |
| 940 | [Distinct Subsequences II](https://leetcode.com/contest/weekly-contest-110/problems/distinct-subsequences-ii/) | Hard | [WIP](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/DistinctSubsequences2.scala) | NA | NA |
| 970 | [Powerful Integers](https://leetcode.com/contest/weekly-contest-118/problems/powerful-integers/) | Easy | [Scala](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/PowerfulIntegers.scala) | 296 | 42.2 |
| 973 | [K Closest Points to Origin](https://leetcode.com/contest/weekly-contest-119/problems/k-closest-points-to-origin/) | Easy | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/KClosestPointsToOrigin.java) | 64 | 54.5 |
| 981 | [Time Based Key-Value Store](https://leetcode.com/contest/weekly-contest-121/problems/time-based-key-value-store) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/TimeBasedKeyValueStore.java) | 489 | 134 |
| 983 | [Minimum Cost For Tickets](https://leetcode.com/contest/weekly-contest-121/problems/minimum-cost-for-tickets/) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/MinimumCostForTickets.java) / [Scala](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/MinimumCostForTickets.scala) | 10 / 348 | 26 / 45.6 |
| 986 | [Interval List Intersections](https://leetcode.com/contest/weekly-contest-122/problems/interval-list-intersections/) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/IntervalListIntersections.java) | 9 | 31.1 |
| 987 | [Vertical Order Traversal of a Binary Tree](https://leetcode.com/contest/weekly-contest-122/problems/vertical-order-traversal-of-a-binary-tree/) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/VerticalOrderTraversalOfBinaryTree.java) | 5 | 26.5 |
| 988 | [Smallest String Starting From Leaf](https://leetcode.com/problems/smallest-string-starting-from-leaf/) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/SmallestStringStartingFromLeaf.java) | 12 | 26.3 |
| 989 | [Add to Array-Form of Integer](https://leetcode.com/contest/weekly-contest-123/problems/add-to-array-form-of-integer) | Easy | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/AddToArrayFormOfInteger.java) | 36 | 32.7 |
| 990 | [Satisfiability of Equality Equations](https://leetcode.com/contest/weekly-contest-123/problems/satisfiability-of-equality-equations/) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/SatisfiabilityOfEqualityEquations.java) | 88 | 41.5 |
| 991 | [Broken Calculator](https://leetcode.com/contest/weekly-contest-123/problems/broken-calculator/) | Medium | [Java](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/BrokenCalculator.java) / [Scala](https://github.com/aa8y/leetcode/blob/master/scala/src/main/scala/co/aa8y/leetcode/BrokenCalculator.scala) | 1427 / 264 | 26 / 40 |
| 1000 | [Minimum Cost to Merge Stones](https://leetcode.com/contest/weekly-contest-126/problems/minimum-cost-to-merge-stones/) | Hard | [WIP](https://github.com/aa8y/leetcode/blob/master/java/src/main/java/co/aa8y/leetcode/MinimumCostToMergeStones.java) | NA | NA |