Implement Stack using Queue

Implement Stack using Queue in Java

You are given a Queue data structure that supports standard enQueue and deQueue operations. 
You need to implement Stack data structure using Queue instances.

Lets understand the problem statement graphically and it will be more clear, 

Find Smallest and Second smallest element in array.

Find Smallest and Second smallest number in array.

Given a integer array, find smallest and second smallest number in array.

Lets understand the problem statement graphically and it will be more clear,
find smallest and second smallest element in an array in java
Find smallest and second smallest element in an array in Java

Find Largest and Second Largest number in array

Find Largest and Second Largest number in array

Given a integer array, find largest and second largest number in array.

Lets understand the problem statement graphically and it will be more clear,

find the largest and second largest element in an array
Find the largest and second largest element in an array

Find Largest and Second Largest number in array and Find Smallest and Second Smallest number in array

Find Largest and Second Largest number in array OR Find the smallest and second smallest element in array.

Given a integer array, find largest and second largest number in array. 

Lets understand the problem statement graphically and it will be more clear,

find largest and second largest number in array
Find largest and second largest number in array

Find Largest and Smallest number in Array

Find minimum and maximum number in array

Given a integer array, find minimum and maximum number in array.

Lets understand the problem statement graphically and it will be more clear,
find min and max in array java
Find minimum and maximum element in an array in Java

Count zeros in a row wise and column wise sorted matrix

Count zeros in sorted matrix

Count zeros in a row wise and column wise sorted matrix Lets understand the problem statement graphically and it will be more clear,

Search in a row wise and column wise sorted matrix

Find number in sorted matrix

Given an n x n matrix, where every row and column is sorted in increasing order.  Given a number k, how to decide whether this k is in the matrix. OR Search number in a row wise and column wise sorted matrix.

Lets understand the problem statement graphically and it will be more clear,

Find middle element of a linked list

Find middle element of a linked list in Java

Given a singly linked list find middle of the linked list.

Find Nth node from last in a linked list

Lets understand the problem statement graphically and it will be more clear,


Convert Sorted Linked List to balanced BST

Convert Sorted Linked list to balanced Binary Search Tree

Convert sorted list to binary search tree

Lets simplify the question statement, Given a singly Linked List where elements are sorted in  ascending order convert it to a height balanced BST.

A Binary Search Tree is called balanced if the height of left subtree and height of right subtree of Root differ by at most 1.

Lets understand the problem statement graphically and it will be more clear,

Sorted Array to Balanced Binary Search Tree (BST)

Convert Sorted Array to Balanced Binary Search Tree

Given a sorted array, create a Balanced Binary Search Tree using array elements. A Binary Search Tree is called Balanced if, the height of left subtree and height of right subtree of Root differ by at most 1.

Lets understand the problem statement graphically and it will be more clear,