# Category: Fundamentals

## Fix a function that assigns event handler functions to an array of nodes the wrong way

Fix the following function. When you click on a node, an alert box is supposed to display the ordinal of the node. But it always displays the number of nodes + 1 instead. [codepen_embed...

## Time Conversion: 12 hour to 24 hour format

Convert 12 hour clock to 24 hour clock. Solution

## find pivot in an sorted rotated array

Problem : Given a sorted and rotated array find the index of a pivot element in an array. Input : An array Output : An index Algorithm : Binary search tree Time complexity :...

## Dedupe an array in javascript

Input : An array Output : An array Logic : Iterate over the input array called data Add the element to the output array called result if the element does not exist in the...

## Algorithm: find unique characters in a string using javascript

Problem : Given a string find all the unique characters in the stirng. Input : A string Output : A string Logic : Iterate over entire string and create a frequency map If the...

## Queue using two stacks javascript

Problem : Implement queue’s enqueue and dequeue operations using two stacks. Logic: The queue is first-in-first-out and a stack is last in-first-out phenomena. Hence, the main difference between these two data structures is that...

## Sort the stack in ascending order

Problem : Sort the given stack into an ascending order without using recursion. Logic: Pop an item from the original stack and push it onto the sorted stack. If the poped item from the...

## Introduction to backtracking

Backtracking is a general algorithmic technique that considers searching every possible combination in order to solve a problem. It is also known as depth-first search or branch and bound. It is an important tool...

## Flatten nested array javascript

Problem : Given a nested array, flatten the given array. Input : [1, 2, 3, [4, 5], [6, [7, 8]]] Output : [1, 2, 3, 4, 5, 6, 7, 8] Logic : Iterate throgh...

## Replace all spaces in a string with %20

The solution is self explanatory. Solution :