# Category: Uncategorized

## Minimum Absolute Difference in an Array

Given an array of integers, find and print the minimum absolute difference between any two elements in the array. For example, Input: -59 -36 -13 1 -53 -92 -2 -96 -54 75 Output: 1...

## Programming shorthands / tricks

Different ways to track the max value while iterating over different values We can use if, ternary operator or Math.max function as shown below. if (val > max) {   max = val...

## How to get the number from the middle of a string

Given the following string extract the number ‘Buy for \$199.99’ // 199.99 ‘Gas Price \$2.304 per gallon’ // 2.304 We can solve this using slice and, parseFloat(). slice returns the string from the starting...

## Delete all the nodes from a binary tree

Recursive : To delete all the nodes, you will have to visit all the nodes. There are three ways to traverse the binary tree : Post order Pre order In order. To delete all...

## Create a bar chart from json

Problem : Given a JSON data structure with key representing age and value representing the number of people with that age. For example, { 25: 55, 26: 45, 27: 10, 28: 20, 30: 1,...