Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/ignacio-chiazzo/algorithms-leetcode-javascript

Algorithms resolution in Javascript. Leetcode - Geeksforgeeks - Careercup
https://github.com/ignacio-chiazzo/algorithms-leetcode-javascript

algorithms algortithms coding-interviews computer-science data-structures hackoctoberfest hackoctoberfest2022 hacktoberfest hacktoberfest-accepted interview interview-preparation interview-questions javascript leetcode leetcode-javascript leetcode-solutions problem-solving problemsolving programming-interviews study-plan

Last synced: 3 days ago
JSON representation

Algorithms resolution in Javascript. Leetcode - Geeksforgeeks - Careercup

Awesome Lists containing this project

README

        

# Algorithms-Javascript

Solutions of algorithm problems using Javascript. https://ignacio-chiazzo.github.io/Algorithms-Leetcode-Javascript/

### Structure
The solutions are located under `/LeetcodeProblems`. Each problem has a test file located under `/LeetcodeProblemsTest`.

### Run Tests

**Unit tests:** To run all the test run `node Test.js` in the console. To run a specific problem in your console run `node Test.js ` (e.g. `node Test.js ./LeetcodeProblemsTests/Algorithms/easy/2Sum_Test.js`).

**Linter:** This repository uses [`es-lint`](https://eslint.org/docs/latest/user-guide/command-line-interface). To run all the tests you would need to install the packages by running `npm install` followed by `npx eslint LeetcodeProblems LeetcodeProblemsTests` which will run the eslint in all problems and tests. You can also use the [flag `--fix`](https://eslint.org/docs/latest/user-guide/command-line-interface#fixing-problems) which will automatically fix some of the errors.

### Leetcode Problems

| Name | Level | Link |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|---------------------------------------------------------------------------------------------------------------------|
| [Edit Distance ](/LeetcodeProblems/Algorithms/hard/Edit_Distance.js) | Hard | https://leetcode.com/problems/edit-distance/ |
| [First Missing Positive ](/LeetcodeProblems/Algorithms/hard/First_Missing_Positive.js) | Hard | https://leetcode.com/problems/first-missing-positive/ |
| [Remove Invalid Parentheses ](/LeetcodeProblems/Algorithms/hard/Remove_Invalid_Parentheses.js) | Hard | https://leetcode.com/problems/remove-invalid-parentheses/ |
| [Longest Consecutive Sequence ](/LeetcodeProblems/Algorithms/hard/Longest_Consecutive_Sequence.js) | Hard | https://leetcode.com/problems/longest-consecutive-sequence/ |
| [Minimum Window Substring ](/LeetcodeProblems/Algorithms/hard/Minimum_Window_Substring.js) | Hard | https://leetcode.com/problems/minimum-window-substring/ |
| [Regular Expression Matching ](/LeetcodeProblems/Algorithms/hard/Regular_Expression_Matching.js) | Hard | https://leetcode.com/problems/regular-expression-matching/ |
| [NQueens ](/LeetcodeProblems/Algorithms/hard/NQueens.js) | Hard | https://leetcode.com/problems/n-queens/ |
| [merge k sorted lists ](/LeetcodeProblems/Algorithms/hard/merge_k_sorted_lists.js) | Hard | https://leetcode.com/problems/merge-k-sorted-lists/ |
| [Set Matrix Zeroes](/LeetcodeProblems/Algorithms/hard/Set_Matrix_Zeroes.js) | Hard | https://leetcode.com/problems/set-matrix-zeroes/ |
| [Subarray Sum Equals K ](/LeetcodeProblems/Algorithms/medium/Subarray_Sum_Equals_K.js) | Medium | https://leetcode.com/problems/subarray-sum-equals-k/ |
| [3Sum Closest](/LeetcodeProblems/Algorithms/medium/3SumClosest.js) | Medium | https://leetcode.com/problems/3sum-closest/ |
| [3Sum ](/LeetcodeProblems/Algorithms/medium/3Sum.js) | Medium | https://leetcode.com/problems/3sum/ |
| [NumberOfIslands ](/LeetcodeProblems/Algorithms/medium/Number_of_Islands.js) | Medium | https://leetcode.com/problems/number-of-islands/ |
| [Swap Nodes in Pairs](/LeetcodeProblems/Algorithms/medium/Swap_Nodes_in_Pairs.js) | Medium | https://leetcode.com/problems/swap-nodes-in-pairs/ |
| [Add Two Numbers ](/LeetcodeProblems/Algorithms/medium/Add_Two_Numbers.js) | Medium | https://leetcode.com/problems/add-two-numbers/ |
| [Clone Graph ](/LeetcodeProblems/Algorithms/medium/Clone_Graph.js) | Medium | https://leetcode.com/problems/clone-graph/ |
| [Coin Change ](/LeetcodeProblems/Algorithms/medium/Coin_Change.js) | Medium | https://leetcode.com/problems/coin-change/ |
| [Container With Most Water](/LeetcodeProblems/Algorithms/medium/Container_With_Most_Water.js) | Medium | https://leetcode.com/problems/container-with-most-water/ |
| [Design Circular Deque ](/LeetcodeProblems/Algorithms/medium/Design_Circular_Deque.js) | Medium | https://leetcode.com/problems/design-circular-deque/
| [Escape The Ghosts](/LeetcodeProblems/Algorithms/medium/Escape_The_Ghosts.js) | Medium | https://leetcode.com/problems/escape-the-ghosts/ |
| [Find All Anagrams in a String](/LeetcodeProblems/Algorithms/medium/Find_Anagrams.js) | Medium | https://leetcode.com/problems/find-all-anagrams-in-a-string/ |
| [Generate Parenthesis ](/LeetcodeProblems/Algorithms/medium/Generate_Parenthesis.js) | Medium | https://leetcode.com/problems/generate-parentheses |
| [Group Anagrams ](/LeetcodeProblems/Algorithms/medium/Group_Anagrams.js) | Medium | https://leetcode.com/problems/group-anagrams/
| [Kth Largest Element in an Array ](/LeetcodeProblems/Algorithms/medium/Kth_Largest_Element_in_an_Array.js) | Medium | https://leetcode.com/problems/kth-largest-element-in-an-array/ |
| [Linked List Cycle II ](/LeetcodeProblems/Algorithms/medium/Linked_List_Cycle_II.js) | Medium | https://leetcode.com/problems/linked-list-cycle-ii/ |
| [Longest Palindromic Substring ](/LeetcodeProblems/Algorithms/medium/Longest_Palindromic_Substring.js) | Medium | https://leetcode.com/problems/longest-palindromic-substring/ |
| [Longest Substring Without Reapeating Characters](/LeetcodeProblems/Algorithms/medium/Longest_Substring.js) | Medium | https://leetcode.com/problems/longest-substring-without-repeating-characters |
| [Max Area Of Island ](/LeetcodeProblems/Algorithms/medium/Max_Area_Of_Island.js) | Medium | https://leetcode.com/problems/max-area-of-island/ |
| [Max Consecutive Ones III ](/LeetcodeProblems/Algorithms/medium/Max_Consecutive_Ones_III.js) | Medium | https://leetcode.com/problems/max-consecutive-ones-iii |
| [Maximal Square ](/LeetcodeProblems/Algorithms/medium/Maximal_Square.js) | Medium | https://leetcode.com/problems/maximal-square/ |
| [Minimum Add to Make Parentheses Valid ](/LeetcodeProblems/Algorithms/medium/Minimum_Add_To_Make_Parentheses_Valid.js) | Medium | https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/ |
| [Minimum Size Subarray](/LeetcodeProblems/Algorithms/medium/Minimum_Size_Subarray.js) | Medium | https://leetcode.com/problems/minimum-size-subarray-sum |
| [Permutations ](/LeetcodeProblems/Algorithms/medium/Permutations.js) | Medium | https://leetcode.com/problems/permutations/ |
| [Permutations II ](/LeetcodeProblems/Algorithms/medium/Permutations_II.js) | Medium | https://leetcode.com/problems/permutations-ii/ |
| [Permutation in String](/LeetcodeProblems/Algorithms/medium/Permutations_In_String.js) | Medium | https://leetcode.com/problems/permutation-in-string/ |
| [Permutations Without Duplicates ](/LeetcodeProblems/Algorithms/medium/Permutations_Without_Duplicates.js) | Medium | https://leetcode.com/problems/permutations/ |
| [Restore IP Addresses ](/LeetcodeProblems/Algorithms/medium/Restore_IP_Addresses.js) | Medium | https://leetcode.com/problems/restore-ip-addresses/ |
| [SearchIng Rotated Sorted Array ](/LeetcodeProblems/Algorithms/medium/SearchIng_Rotated_Sorted_Array.js) | Medium | https://leetcode.com/problems/search-in-rotated-sorted-array/ |
| [Search a 2D Matrix ](/LeetcodeProblems/Algorithms/medium/Search_a_2D_Matrix.js) | Medium | https://leetcode.com/problems/search-a-2d-matrix/ |
| [Search a 2D Matrix II ](/LeetcodeProblems/Algorithms/medium/Search_a_2D_Matrix_II.js) | Medium | https://leetcode.com/problems/search-a-2d-matrix/ |
| [Simplify Path ](/LeetcodeProblems/Algorithms/medium/Simplify_Path.js) | Medium | https://leetcode.com/problems/simplify-path/ |
| [Spiral Matrix ](/LeetcodeProblems/Algorithms/medium/Spiral_Matrix.js) | Medium | https://leetcode.com/problems/spiral-matrix/ |
| [Subsets ](/LeetcodeProblems/Algorithms/medium/Subsets.js) | Medium | https://leetcode.com/problems/subsets/ |
| [Unique Binary Search Trees ](/LeetcodeProblems/Algorithms/medium/Unique_Binary_Search_Trees.js) | Medium | https://leetcode.com/problems/unique-binary-search-trees/ |
| [Unique Paths ](/LeetcodeProblems/Algorithms/medium/Unique_Paths.js) | Medium | https://leetcode.com/problems/unique-paths/ |
| [Verify Preorder Serialization of a Binary Tree ](/LeetcodeProblems/Algorithms/medium/Verify_Preorder_Serialization_of_a_Binary_Tree.js) | Medium | https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree/ |
| [Construct Binary Tree from Preorder and Inorder Traversal ](/LeetcodeProblems/Algorithms/medium/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.js) | Medium | https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ |
| [Lowest Common Ancestor of a Binary Tree ](/LeetcodeProblems/Algorithms/medium/Lowest_Common_Ancestor_of_a_Binary_Tree.js) | Medium | https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/ |
| [Maximum Sum of an Hourglass](/LeetcodeProblems/Algorithms/medium/Maximise_Hour_Glass_Sum.js) | Medium | https://leetcode.com/problems/maximum-sum-of-an-hourglass/ |
| [Next Permutation](/LeetcodeProblems/Algorithms/medium/Next_Permutation.js) | Medium | https://leetcode.com/problems/next-permutation/ |
| [Time Needed to Rearrange a Binary String](/LeetcodeProblems/Algorithms/medium/Time_Needed_Rearrange_Binary_String.js) | Medium | https://leetcode.com/problems/time-needed-to-rearrange-a-binary-string/ |
| [Find Subarrays With Equal Sum ](/LeetcodeProblems/Algorithms/medium/Find_Subarrays_With_Equal_Sums.js) | Medium | https://leetcode.com/problems/find-subarrays-with-equal-sum/ |
| [Reverse Integer](/LeetcodeProblems/Algorithms/medium/Reverse_Integer.js) | Medium | https://leetcode.com/problems/reverse-integer/ |
| [Minimize Maximum Pair Sum in Array ](/LeetcodeProblems/Algorithms/medium/Minimize_Maximum_Pair_Sum_In_Array.js) | Medium | https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/ |
| [Top K Frequent Elements ](/LeetcodeProblems/Algorithms/medium/Top_K_Frequent_Elements.js) | Medium | https://leetcode.com/problems/top-k-frequent-elements/ |
| [Gas Station](/LeetcodeProblems/Algorithms/medium/GasStation/index.js) | Medium | https://leetcode.com/problems/gas-station/description/ |
| [K Closest Points to Origin](/LeetcodeProblems/Algorithms/medium/K_Closest_Points_to_Origin.js/) | Medium | https://leetcode.com/problems/k-closest-points-to-origin/
| [BestTimeToBuy](LeetcodeProblems/Algorithms/easy/Best_Time_To_Buy_And_Sell_Stock_II.js) | Medium | https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii |
| [Best Time to Buy and Sell Stock](/LeetcodeProblems/Algorithms/easy/Best_Time_to_buy_and_sell_stock.js) | Easy | https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
| [Flood Fill ](/LeetcodeProblems/Algorithms/easy/Flood_Fill.js) | Easy | https://leetcode.com/problems/flood-fill/ |
| [Implement stack using queues ](/LeetcodeProblems/Algorithms/easy/Implement_stack_using_queues.js) | Easy | https://leetcode.com/problems/implement-stack-using-queues/ |
| [Number of Segments in a String ](/LeetcodeProblems/Algorithms/easy/Number_of_Segments_in_a_String.js) | Easy | https://leetcode.com/problems/number-of-segments-in-a-string/ |
| [Maximun Subarray ](/LeetcodeProblems/Algorithms/easy/Maximun_Subarray.js) | Easy | https://leetcode.com/problems/maximum-subarray |
| [Min Stack ](/LeetcodeProblems/Algorithms/easy/Min_Stack.js) | Easy | https://leetcode.com/problems/min-stack/ |
| [Reverse String II ](/LeetcodeProblems/Algorithms/easy/Reverse_String_II.js) | Easy | https://leetcode.com/problems/reverse-string-ii/ |
| [Same Tree ](/LeetcodeProblems/Algorithms/easy/Same_Tree.js) | Easy | https://leetcode.com/problems/same-tree/ |
| [Sum Of Square Numbers ](/LeetcodeProblems/Algorithms/easy/Sum_Of_Square_Numbers.js) | Easy | https://leetcode.com/problems/sum-of-square-numbers/ |
| [Symmetric Tree ](/LeetcodeProblems/Algorithms/easy/Symmetric_Tree.js) | Easy | https://leetcode.com/problems/symmetric-tree/ |
| [Valid Parentheses ](/LeetcodeProblems/Algorithms/easy/Valid_Parentheses.js) | Easy | https://leetcode.com/problems/valid-parentheses/ |
| [Backspace String Compare ](/LeetcodeProblems/Algorithms/easy/Backspace_String_Compare.js) | Easy | https://leetcode.com/problems/backspace-string-compare/ |
| [Binary Gap ](/LeetcodeProblems/Algorithms/easy/Binary_Gap.js) | Easy | https://leetcode.com/problems/binary-gap/ |
| [Majority Element](/LeetcodeProblems/Algorithms/easy/Majority_Element.js) | Easy | https://leetcode.com/problems/majority-element/ |
| [Lexographically Smallest String After A Swap](/LeetcodeProblems/Algorithms/medium/Kth_Largest_Element_in_an_Array.js) | Easy | https://leetcode.com/problems/lexicographically-smallest-string-after-a-swap/ |
| [Longest Common Prefix](/LeetcodeProblems/Algorithms/easy/Longest_Common_Prefix.js) | Easy | https://leetcode.com/problems/longest-common-prefix/ |
| [Two Sum](/LeetcodeProblems/Algorithms/easy/2Sum.js) | Easy | https://leetcode.com/problems/two-sum/ |
| [Tic Tac Toe ](/LeetcodeProblems/Algorithms/easy/Tic_Tac_Toe.js) | Easy | |
| [Permutations With Duplicates ](/LeetcodeProblems/Algorithms/easy/Permutations_With_Duplicates.js) | Easy | |
| [Deletion Distance](/LeetcodeProblems/Algorithms/easy/Deletion_Distance.js) | Easy | |
| [Award Budget Cuts](/LeetcodeProblems/Algorithms/easy/Award_Budget_Cuts.js) | Easy | |
| [Happy Number](/LeetcodeProblems/Algorithms/easy/Happy_Number.js) | Easy | https://leetcode.com/problems/happy-number/ |
| [Shuffle String](/LeetcodeProblems/Algorithms/easy/Shuffle_String.js) | Easy | https://leetcode.com/problems/shuffle-string/ |
| [Reverse bit to make number equal](/LeetcodeProblems/Algorithms/easy/Bit_Reverse_To_Make_Numbers_Equal.js.js) | Easy | https://leetcode.com/problems/number-of-bit-changes-to-make-two-integers-equal/ |

### Sorting Algorithms
| Algoritmhs |
| - |
| [Heap Sort](/SortingAlgorithms/heapSort.js) |
| [Quick Sort](/SortingAlgorithms/QuickSort.js) |

### Databases
| Problems | Level | Link |
|-|-|-|
| [Trips and Users](/LeetcodeProblems/Databases/hard/Trips_and_Users.sql) | Hard | https://leetcode.com/problems/trips-and-users/ |
| [Human Traffic of Stadium](/LeetcodeProblems/Databases/hard/Human_Traffic_of_Stadium.sql) | Hard | https://leetcode.com/problems/human-traffic-of-stadium |
| [Rank Scores](/LeetcodeProblems/Databases/medium/Rank_Scores.sql) | Medium | https://leetcode.com/problems/rank-scores |
| [Consecutive Numbers](/LeetcodeProblems/Databases/medium/Consecutive_Numbers.sql) | Medium | https://leetcode.com/problems/consecutive-numbers |
| [Department Highest Salary](/LeetcodeProblems/Databases/medium/Department_Highest_Salary.sql) | Medium | https://leetcode.com/problems/department-highest-salary |
| [Exchange Seats](/LeetcodeProblems/Databases/medium/Exchange_Seats.sql) | Medium | https://leetcode.com/problems/exchange-seats |
| [Nth Highest Salary](/LeetcodeProblems/Databases/medium/nth_Highest_Salary.sql) | Medium | https://leetcode.com/problems/nth-highest-salary |
| [Combine Two Tables](/LeetcodeProblems/Databases/easy/Combine_Two_Tables.sql) | Easy | https://leetcode.com/problems/combine-two-tables |
| [Second Highest Salary](/LeetcodeProblems/Databases/easy/Second_highest_salary.sql)| Easy | https://leetcode.com/problems/second-highest-salary |
| [Customers Who Never Order](/LeetcodeProblems/Databases/easy/Customers_Who_Never_Order.sql)| Easy | https://leetcode.com/problems/customers-who-never-order |
| [Reformat Department Table](/LeetcodeProblems/Databases/easy/Reformat_Department_Table.sql) | Easy | https://leetcode.com/problems/reformat-department-table |
| [Employees Earning More Than Their Managers](/LeetcodeProblems/Databases/easy/Employees_Earning_More_Than_Their_Managers.sql) | Easy | https://leetcode.com/problems/employees-earning-more-than-their-managers/ |
| [Delete Duplicate Emails](LeetcodeProblems/Databases/easy/Delete_Duplicate_Emails.sql) | Easy | https://leetcode.com/problems/delete-duplicate-emails |
| [Rising Temperature](LeetcodeProblems/Databases/easy/Rising_Temperature.sql) | Easy | https://leetcode.com/problems/rising-temperature |

### UtilsClasses

Other languages provides built-in classes (e.g Linked List, Tree, etc). This module contains util classes to use in your problems.

### Contributions

I'd be pleased to accept contributions. I'd be happy to discuss problems and solutions over a Pull Request or an Issue.

Each problem should have:

1) A description of the problem at the top of the file.
2) A test file with some test cases. The test file must export a `test()` function which should run all the tests of the file.
3) An entry of the problem in the list of solutions within the README file.

PR Example: https://github.com/ignacio-chiazzo/Algorithms-Leetcode-Javascript/pull/39