Algorithms Resolution in Javascript


Solutions of algorithm problems using Javascript. 


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

Run Tests

To run all the test run node Test.js in the console.

To run a specific problem in your console run node <problem_file_path> (e.g. node LeetcodeProblems/Lowest_Common_Ancestor_of_a_Binary_Tree.js).

Leetcode Problems

Edit DistanceHard
Remove Invalid ParenthesesHard
Longest Consecutive SequenceHard
Minimum Window SubstringHard
Regular Expression MatchingHard
merge k sorted listsHard
Set Matrix ZeroesHard
Subarray Sum Equals KMedium
Swap Nodes in PairsMedium
Add Two NumbersMedium
Clone GraphMedium
Coin ChangeMedium
Design Circular DequeMedium
Escape The GhostsMedium
Generate ParenthesisMedium
Group AnagramsMedium
Kth Largest Element in an ArrayMedium
Linked List Cycle IIMedium
Longest Palindromic SubstringMedium
Max Area Of IslandMedium
Maximal SquareMedium
Permutations IIMedium
Permutations Without DuplicatesMedium
Restore IP AddressesMedium
SearchIng Rotated Sorted ArrayMedium
Search a 2D MatrixMedium
Search a 2D Matrix IIMedium
Simplify PathMedium
Spiral MatrixMedium
Unique Binary Search TreesMedium
Unique PathsMedium
Verify Preorder Serialization of a Binary TreeMedium
Construct Binary Tree from Preorder and Inorder TraversalMedium
Lowest Common Ancestor of a Binary TreeMedium
Flood FillEasy
Implement stack using queuesEasy
Number of Segments in a StringEasy
Maximun SubarrayEasy
Min StackEasy
Reverse String IIEasy
Same TreeEasy
Sum Of Square NumbersEasy
Symmetric TreeEasy
Valid ParenthesesEasy
Backspace String CompareEasy
Binary GapEasy
Binary GapEasy
Majority ElementEasy
Tic Tac Toe  
Permutations With Duplicates  
Deletion Distance  
Award Budget Cuts  

Sorting Algorithms

Heap Sort
Quick Sort


Trips and UsersHard
Human Traffic of StadiumHard
Rank ScoresMedium
Consecutive NumbersMedium
Department Highest SalaryMedium
Exchange SeatsMedium
Nth Highest SalaryMedium
Combine Two TablesEasy
Second Highest SalaryEasy
Customers Who Never OrderEasy
Reformat Department TableEasy
Employees Earning More Than Their ManagersEasy
Delete Duplicate EmailsEasy
Rising TemperatureEasy


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


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:


Author: ignacio-chiazzo
Source Code: 
License: MIT license

#algorithm #javascript 

What is GEEK

Buddha Community

Algorithms Resolution in Javascript

Javascript-algorithms: JavaScript Algorithms and Data Structures

JavaScript Algorithms and Data Structures

This repository contains JavaScript based examples of many popular algorithms and data structures.

Each algorithm and data structure has its own separate README with related explanations and links for further reading (including ones to YouTube videos).

Read this in other languages: 简体中文, 繁體中文, 한국어, 日本語, Polski, Français, Español, Português, Русский, Türkçe, Italiana, Bahasa Indonesia, Українська, Arabic, Tiếng Việt, Deutsch

☝ Note that this project is meant to be used for learning and researching purposes only, and it is not meant to be used for production.

Data Structures

A data structure is a particular way of organizing and storing data in a computer so that it can be accessed and modified efficiently. More precisely, a data structure is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data.

B - Beginner, A - Advanced


An algorithm is an unambiguous specification of how to solve a class of problems. It is a set of rules that precisely define a sequence of operations.

B - Beginner, A - Advanced

Algorithms by Topic

Algorithms by Paradigm

An algorithmic paradigm is a generic method or approach which underlies the design of a class of algorithms. It is an abstraction higher than the notion of an algorithm, just as an algorithm is an abstraction higher than a computer program.

How to use this repository

Install all dependencies

npm install

Run ESLint

You may want to run it to check code quality.

npm run lint

Run all tests

npm test

Run tests by name

npm test -- 'LinkedList'


If linting or testing is failing, try to delete the node_modules folder and re-install npm packages:

rm -rf ./node_modules
npm i

Also make sure that you're using a correct Node version (>=14.16.0). If you're using nvm for Node version management you may run nvm use from the root folder of the project and the correct version will be picked up.


You may play with data-structures and algorithms in ./src/playground/playground.js file and write tests for it in ./src/playground/__test__/playground.test.js.

Then just simply run the following command to test if your playground code works as expected:

npm test -- 'playground'

Useful Information


Big O Notation

Big O notation is used to classify algorithms according to how their running time or space requirements grow as the input size grows. On the chart below you may find most common orders of growth of algorithms specified in Big O notation.

Big O graphs

Source: Big O Cheat Sheet.

Below is the list of some of the most used Big O notations and their performance comparisons against different sizes of the input data.

Big O NotationTypeComputations for 10 elementsComputations for 100 elementsComputations for 1000 elements
O(log N)Logarithmic369
O(N log N)n log(n)306009000

Data Structure Operations Complexity

Data StructureAccessSearchInsertionDeletionComments
Linked Listnn1n 
Hash Table-nnnIn case of perfect hash function costs would be O(1)
Binary Search TreennnnIn case of balanced tree costs would be O(log(n))
Red-Black Treelog(n)log(n)log(n)log(n) 
AVL Treelog(n)log(n)log(n)log(n) 
Bloom Filter-11-False positives are possible while searching

Array Sorting Algorithms Complexity

Bubble sortnn2n21Yes 
Insertion sortnn2n21Yes 
Selection sortn2n2n21No 
Heap sortn log(n)n log(n)n log(n)1No 
Merge sortn log(n)n log(n)n log(n)nYes 
Quick sortn log(n)n log(n)n2log(n)NoQuicksort is usually done in-place with O(log(n)) stack space
Shell sortn log(n)depends on gap sequencen (log(n))21No 
Counting sortn + rn + rn + rn + rYesr - biggest number in array
Radix sortn * kn * kn * kn + kYesk - length of longest key

Project Backers

You may support this project via ❤️️ GitHub or ❤️️ Patreon.

Folks who are backing this project ∑ = 0

ℹ️ A few more projects and articles about JavaScript and algorithms on

Download Details:

Author: trekhleb
Source Code: 
License: MIT license

#javascript #computerscience #algorithm #algorithms 

Rahul Jangid


What is JavaScript - Stackfindover - Blog

Who invented JavaScript, how it works, as we have given information about Programming language in our previous article ( What is PHP ), but today we will talk about what is JavaScript, why JavaScript is used The Answers to all such questions and much other information about JavaScript, you are going to get here today. Hope this information will work for you.

Who invented JavaScript?

JavaScript language was invented by Brendan Eich in 1995. JavaScript is inspired by Java Programming Language. The first name of JavaScript was Mocha which was named by Marc Andreessen, Marc Andreessen is the founder of Netscape and in the same year Mocha was renamed LiveScript, and later in December 1995, it was renamed JavaScript which is still in trend.

What is JavaScript?

JavaScript is a client-side scripting language used with HTML (Hypertext Markup Language). JavaScript is an Interpreted / Oriented language called JS in programming language JavaScript code can be run on any normal web browser. To run the code of JavaScript, we have to enable JavaScript of Web Browser. But some web browsers already have JavaScript enabled.

Today almost all websites are using it as web technology, mind is that there is maximum scope in JavaScript in the coming time, so if you want to become a programmer, then you can be very beneficial to learn JavaScript.

JavaScript Hello World Program

In JavaScript, ‘document.write‘ is used to represent a string on a browser.

<script type="text/javascript">
	document.write("Hello World!");

How to comment JavaScript code?

  • For single line comment in JavaScript we have to use // (double slashes)
  • For multiple line comments we have to use / * – – * /
<script type="text/javascript">

//single line comment

/* document.write("Hello"); */


Advantages and Disadvantages of JavaScript

#javascript #javascript code #javascript hello world #what is javascript #who invented javascript

Hire Dedicated JavaScript Developers -Hire JavaScript Developers

It is said that a digital resource a business has must be interactive in nature, so the website or the business app should be interactive. How do you make the app interactive? With the use of JavaScript.

Does your business need an interactive website or app?

Hire Dedicated JavaScript Developer from WebClues Infotech as the developer we offer is highly skilled and expert in what they do. Our developers are collaborative in nature and work with complete transparency with the customers.

The technology used to develop the overall app by the developers from WebClues Infotech is at par with the latest available technology.

Get your business app with JavaScript

For more inquiry click here

Book Free Interview:

#hire dedicated javascript developers #hire javascript developers #top javascript developers for hire #hire javascript developer #hire a freelancer for javascript developer #hire the best javascript developers

Niraj Kafle


The essential JavaScript concepts that you should understand

As a JavaScript developer of any level, you need to understand its foundational concepts and some of the new ideas that help us developing code. In this article, we are going to review 16 basic concepts. So without further ado, let’s get to it.

#javascript-interview #javascript-development #javascript-fundamental #javascript #javascript-tips

Ajay Kapoor


JS Development Company India | JavaScript Development Services

PixelCrayons: Our JavaScript web development service offers you a feature-packed & dynamic web application that effectively caters to your business challenges and provide you the best RoI. Our JavaScript web development company works on all major frameworks & libraries like Angular, React, Nodejs, Vue.js, to name a few.

With 15+ years of domain expertise, we have successfully delivered 13800+ projects and have successfully garnered 6800+ happy customers with 97%+ client retention rate.

Looking for professional JavaScript web app development services? We provide custom JavaScript development services applying latest version frameworks and libraries to propel businesses to the next level. Our well-defined and manageable JS development processes are balanced between cost, time and quality along with clear communication.

Our JavaScript development companies offers you strict NDA, 100% money back guarantee and agile/DevOps approach.

#javascript development company #javascript development services #javascript web development #javascript development #javascript web development services #javascript web development company