Category Archives: Interview Questions

Find second smallest element in an array of integers (java / example)

Given an array of integers in java. Print second smallest element in an array (in single iteration). We have already discussed to find out second largest element in an array of integers. Example – find second smallest element in an array of integers (java). Example 1: Given an input array  {2, 4, 6, 8, 10, 12}. Smallest element… Read More »

Implement two stacks using single array in java (example)

Given an array of integers in java. Create two stacks using single array. We shall able to perform push & pop operations on both stacks. We will create two stacks i.e. stack1 and stack2. stack1 will have following methods. push1 method: push1 method will insert the element to stack1 pop1 method: pop1 method will remove… Read More »

Create or implement stack using array in java (with example)

Create or implement stack in java using array as underlying data structure. We will create stack class having following methods Push method: Push method will be used to insert new element to stack. Pop method: Pop method will remove top element of stack. Size method: Size method will return current size of stack. isEmpty method:… Read More »