## Find consecutive segments in an sorted array

Problem : Number list compressing. Given an sorted array. Input: sorted number list [ 1, 2, 3,10, 25, 26, 30, 31, 32, 33] Output: find consecutive segments print: 1-3, 10, 25-26, 30-33 Logic :...

Problem : Number list compressing. Given an sorted array. Input: sorted number list [ 1, 2, 3,10, 25, 26, 30, 31, 32, 33] Output: find consecutive segments print: 1-3, 10, 25-26, 30-33 Logic :...

Below are some of the test strings with their expected output. Input: aaabc Output: abaca Input: aa Output: No valid output Input: aaaabc Output: No valid output Logic : Create frequency map of the...

Problem description : Given a sorted (increasing order) array with unique integer elements, create a binary search tree (BST) with minimal height. Input : A sorted array with unique integer elements // [0, 1,...

A balanced tree is defined to be a tree such that the heights of the two subtrees of any node never differ more than one. Input : The root of a binary tree Output...

Problem description : Write a function to determine if a singly linked list is a palindrome. Input : A linked list Output : Boolean (true or false) Approach 1: Reverse and compare the linked...

Problem description : Write code to partition a linked list around a value val, such that all nodes less than val come before all nodes greater than or equal to val. Input : A...

Input : A number // 10 Output : An array // [2, 5] Logic : Key here is that we need to check the divisor starting with 2 to the square root of the...

Problem description : Write a function which transforms the given JSON as shown belows : Input : Given an endorsment array with objects containing skill and user keys var endorsements = [ { skill:...

Problem description : Write a function that filters the invalid entries from the given array by removing the following elements : which does not have either id or extension property whose id value is...

Problem description : Write a javascript function that accepts a string argument in the format {digit}d{digit}; where The first digit represents the number of dices. The second digit represents the number of sides. The...