Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Complete A to Z DSA Programming Problems for Beginners & Advanced in JavaScript

License

NotificationsYou must be signed in to change notification settings

imkrunalkanojiya/DSA-Programming-Problems-in-JavaScript

Repository files navigation

Welcome to the repository ofData Structures and Algorithms (DSA) Programming Problems solved using JavaScript byTechAlgoSpotlight. This collection includes a variety of problems categorized by their types and complexity. Each problem is accompanied by a solution.


Array Problems

ProblemDescriptionSolution
Array RotationGiven an integer array A of size N and an integer B, you have to return the same array after rotating it B times towards the right.View
Count Of ElementsGiven an array A of N integers. Count the number of elements that have at least 1 elements greater than itself.View
Good PairGiven an array A and an integer B. A pair(i, j) in the array is a good pair if i != j and (A[i] + A[j] == B). Check if any good pair exist or not.View
Linear Search - Multiple OccurencesGiven an array A and an integer B, find the number of occurrences of B in A.View
Max Min of an ArrayGiven an array A of size N. You need to find the sum of Maximum and Minimum element in the given array.View
Reverse in a rangeGiven an array A of N integers and also given two integers B and C. Reverse the elements of the array A within the given inclusive range [B, C].View
Equilibrium index of an arrayYour task is to find the equilibrium index of the given arrayView
Even numbers in a rangeYou are given an array A of length N and Q queries given by the 2D array B of size Q×2.View
In-place Prefix SumGiven an array A of N integers. Construct prefix sum of the array in the given array itself.View
Product array puzzleGiven an array of integers A, find and return the product array of the same size where the ith element of the product array will be equal to the product of all the elements divided by the ith element of the array.View
Range Sum QueryYou are given an integer array A of length N. You are also given a 2D integer array B with dimensions M x 2, where each row denotes a [L, R] query. For each query, you have to find the sum of all elements from L to R indices in A (0 - indexed).View
Closest MinMaxGiven an array A, find the size of the smallest subarray such that it contains at least one occurrence of the maximum value of the array and at least one occurrence of the minimum value of the array.View
Leaders in an arrayGiven an integer array A containing N distinct integers, you have to find all the leaders in array A. An element is a leader if it is strictly greater than all the elements to its right side.View
Special Subsequences "AG"You have given a string A having Uppercase English letters. You have to find how many times subsequence "AG" is there in the given string.View
Generate all subarraysYou are given an array A of N integers. Return a 2D array consisting of all the subarrays of the arrayView
Maximum Subarray EasyYou are given an integer array C of size A. Now you need to find a subarray (contiguous elements) so that the sum of contiguous elements is maximum. But the sum must not exceed B.View
Subarray in given rangeGiven an array A of length N, return the subarray from B to C.View
Sum of All SubarraysYou are given an integer array A of length N. You have to find the sum of all subarray sums of A.View
Anti DiagonalsGive a N * N square matrix A, return an array of its anti-diagonals. Look at the example for more details.View
Column SumYou are given a 2D integer matrix A, return a 1D integer array containing column-wise sums of original matrix.View
Main Diagonal SumYou are given a N X N integer matrix. You have to find the sum of all the main diagonal elements of A. Main diagonal of a matrix A is a collection of elements A[i, j] such that i = j.View
Matrix TransposeGiven a 2D integer array A, return the transpose of A.View
Minor Diagonal SumYou are given a N X N integer matrix. You have to find the sum of all the minor diagonal elements of A.View
Rotate MatrixYou are given a n x n 2D matrix A representing an image.View
Row SumFind Row Sum of given A array.View
Minimum SwapsGiven an array of integers A and an integer B, find and return the minimum number of swaps required to bring all the numbers less than or equal to B together.View
Spiral Order Matrix IIGiven an integer A, generate a square matrix filled with elements from 1 to A2 in spiral order and return the generated square matrix.View
Subarray with given sum and lengthGiven an array A of length N. Also given are integers B and C. Return 1 if there exists a subarray with length B having sum C and 0 otherwiseView
Sum of even indicesYou are given an array A of length N and Q queries given by the 2D array B of size Q*2. Each query consists of two integers B[i][0] and B[i][1].View

Bit Manipulations

ProblemDescriptionSolution
Any base to decimalYou are given a number A. You are also given a base B. A is a number on base B. You are required to convert the number A into its corresponding value in decimal number system.View
Check bitYou are given two integers A and B. Return 1 if B-th bit in A is set. Return 0 if B-th bit in A is unsetView
Decimal to Any BaseGiven a decimal number A and a base B, convert it into its equivalent number in base B.View
Number of 1 BitsWrite a function that takes an integer and returns the number of 1 bits present in its binary representation.View
Set BitYou are given two integers A and B. Set the A-th bit and B-th bit in 0, and return output in decimal Number System.View
Single NumberGiven an array of integers A, every element appears twice except for one. Find that integer that occurs once.View
Unset i-th bitYou are given two integers A and B. If B-th bit in A is set, make it unset. If B-th bit in A is unset, leave as it is.View

Maths Modular Arithmetic

ProblemDescriptionSolution
Divisibility by 3Given a number in the form of an array A of size N. Each of the digits of the number is represented by A[i]. Check if the number is divisible by 3.View
Power with ModulesYou are given A, B and C . Calculate the value of (A ^ B) % CView
Mod ArrayYou are given a large number in the form of a array A of size N where each element denotes a digit of the number. You are also given a number B. You have to find out the value of A % B and return it.View

Sorting

ProblemDescriptionSolution
Elements RemovalGiven an integer array A of size N. You can remove any element from the array in one operation.View
Factors sortYou are given an array A of N elements. Sort the given array in increasing order of number of distinct factors of each element.View
Largest NumberGiven an array A of non-negative integers, arrange them such that they form the largest number.View
Noble IntegerGiven an integer array A, find if an integer p exists in the array such that the number of integers greater than p in the array equals p.View
Tens Digit SortingGiven an array A of N integers. Sort the array in increasing order of the value at the tens place digit of every number.View

Strings

ProblemDescriptionSolution
Count SortGiven an array A. Sort this array using Count Sort Algorithm and return the sorted array.View
Longest Palindromic SubstringGiven a string A of size N, find and return the longest palindromic substring in A.View
To LowerYou are given a function to_lower() which takes a character array A as an argument. Convert each character of A into lowercase characters if it exists.View
To UpperYou are given a function to_upper() which takes a character array A as an argument. Convert each character of A into uppercase characters if it exists.View
Toggle CaseYou are given a character string A having length N, consisting of only lowercase and uppercase latin letters.View

Hashing

ProblemDescriptionSolution
Count distinct elementsGiven an array A of N integers, return the number of unique elements in the array.View
Frequency of element queryGiven an array A. You have some integers given in the array B. For the i-th number, find the frequency of B[i] in the array A and return a list containing all the frequencies.View
Sub-array with 0 sumGiven an array of integers A, find and return whether the given array contains a non-empty subarray with a sum equal to 0.View

Support

TechAlgoSpotlight

If you find the content of this repo interesting and helpful, use the “Buy me a Coffee” link below to buy me a coffee.

Buy Me A Coffee

gif


Visitors Count

Loading

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp