## Deque Implementation – Java

Java Deque Interface – It’s a linear collection. The Deque interface is a subtype of the util.Queue interface. Deque is acronym of “Double Ended Queue” means it supports insertion and removal of data from both...

@tutorialhorizon

Java Deque Interface – It’s a linear collection. The Deque interface is a subtype of the util.Queue interface. Deque is acronym of “Double Ended Queue” means it supports insertion and removal of data from both...

Objective: Given ‘n’ Nuts and ‘n’ Bolts of different sizes. There is one-to-one mapping between nuts and bolts. Write an algorithm to find all matches between nuts and bolts Note: This problem can also be...

Objective: Given two numbers x and y. write an algorithm to find the number of bits which are to be flipped to convert number x to y. Example x = 10, Y = 20 x...

Objective: Given an array which contains even and odd integers. Write an algorithm to separate even and odd numbers. Example int [] arrA = {1,2,3,4,6,8,7,12}; Output: [12, 2, 8, 4, 6, 3, 7, 1] Approach:...

Objective: Given an array of integer write an algorithm to find 3 elements that sum to a zero. In short a+b+c = 0. Example int a [] = { 3,-1,-7,-4,-5,9,10}; Elements are -4 9 -5...

Objective: Given an array which contains only 0’s and 1’s. write an algorithm to separate 0’s and 1’s. Example int [] arrA = {1,0,1,0,1,1,0,0,0,0,1}; Output: [0, 0, 0, 0, 0, 0, 1, 1, 1, 1,...

Objective: Given an array of integer write an algorithm to find 3 elements that sum to a given number k. In short a+b+c = k. Example: int a [] = { 3,1,7,4,5,9,10} , k =...

Objective: Given an array of integer write an algorithm to find the majority element in it (if exist). Majority Element: If an element appears more than n/2 times in array where n is the size...

Objective: Given an integer check whether it is a perfect square. Example: number = 37 Output: false number = 49 Output: true This is fun puzzle which is asked in the interview. Approach: Say number...

Objective: Given an array of integer write a recursive solution to check if array is sorted. Example: int [] a = {1,2,3,4}; Output: true int [] a = {1,2,3,4,2}; Output: false Approach: This problem can...

Objective: Given an array of integer which 1’s followed by 0’s. Find the starting index of 0. Example: int [] a = {1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0}; First Index from where 0 starts: 10 int [] a = {1,1,1}; ...

Objective: Given an array of integer which is first increasing then decreasing. Find the element in array from which point it starts decreasing. OR Given an array of integer which is first increasing then decreasing....

Objective: Given an array of integers, all the elements are appear twice but one element which appears only once. Write an algorithm to find that element. Example: int [] a = { 1,5,6,2,1,6,4,3,2,5,3}; output:...

Objective: Given two numbers ‘k’ and ‘n’. Write an algorithm to calculate kn. Example: k = 4, n = 5 kn = 45 = 1024 k = 2, n = 3 kn = 23 =...

Objective: Write Given two integers ‘number’ and ‘divisor’, Write an algorithm to find the remainder if ‘number’ is divided by ‘divisor’. Condition: You are not allowed to use modulo or % operator. Example: num =...

%d bloggers like this: