Instantly share code, notes, and snippets.

• Pune, India.
Created July 16, 2020 15:21
There is an array of numbers from 1 to 100 which are not in order. Sort the array in O(N) complexity.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 There is an array of numbers from 1 to 100 which are not in order. Sort the array in O(N) complexity. // implemented the function to sort any given array function sortValues(arrofUnsorted){ var minimum = arrofUnsorted[0]; var maximun = arrofUnsorted[0]; var arrSorted = []; var temp;
Created July 16, 2020 15:14
Given a binary tree, find the height of the binary tree.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 Given a binary tree, find the height of the binary tree. Expected: Input: Root node of the tree Output: Height of the tree. public class BinaryTree { //Represent the node of binary tree public static class Node{ int data; Node left;
Last active July 16, 2020 14:26
Given an array, rotate the array to the right by k steps, where k is non-negative
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 Given an array, rotate the array to the right by k steps, where k is non-negative. Expected: Input: [1,2,7,8,9] & k=3 (3 steps) Output: [7,8,9,1,2] // implemented function to rotate the array in anticlockwise. function rotateRight(arrRotate, step){ // adding the new elements to the end of the array based on the step value. for (var i=0; i