Question: An Array of integers is given, both +ve and -ve. You need to find the two elements such that their sum is closest to zero.
For the below array, program shou...

Share

Given two numbers represented by two linked lists, write a function that returns sum list. The sum list is linked list representation of addition of two input numbers...

Share

Given a binary tree, find height of it. Height of empty tree is 0 and height of below tree is 3.
Example Tree
Recommended: Please solve it on “PRACTICE ...

Share

A binary search tree (BST) is a node based binary tree data structure which has the following properties.
• The left subtree of a node contains only nodes with...

Share

AVL tree is a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees cannot be more than one for all nodes.
An Examp...

Share

We have discussed AVL insertion in the previous post. In this post, we will follow a similar approach for deletion.
Steps to follow for deletion.
To make sure that t...

Share

Given a binary tree (not a binary search tree) and two values say n1 and n2, write a program to find the least common ancestor.
Following is definition of LCA from W...

Share

Given a set of numbers, find the Length of the Longest Arithmetic Progression (LLAP) in it.
Examples:
set[] = {1, 7, 10, 15, 27, 29}
output = 3
The longest arithmet...

Share

An element in a sorted array can be found in O(log n) time via binary search. But suppose we rotate an ascending order sorted array at some pivot unknown to you befo...

Share

Given an array of positive integers. All numbers occur even number of times except one number which occurs odd number of times. Find the number in O(n) time & con...

Share