## Find the first non repeating character in a given string

Objective: Given a string, write an algorithm to find the first non repeating character in it. Example: String input = … Read more

## Find the first repeating character in a given string

Objective: Given a string, write an algorithm to find the first repeating character in it. Example: String input = “horizon … Read more

## Implement Stack Using Linked List

Objective: Write an algorithm to implement Stack using Linked List. If you do not know about then for starters its … Read more

## Search the Element in a binary tree – With and Without Recursion

Objective: Given a binary tree and a given number x, Write a recursive algorithm to search the element in the … Read more

## Find the Kth Smallest/Largest Element in an Array

Objective: Given an array of integers. find the Kth Smallest/largest element in the array. Example int[] A = { 1, … Read more

## Dynamic Programming – Stairs Climbing Puzzle

Objective: A child is climbing up a staircase with n steps, and can hop either 1 step, 2 steps, or … Read more

## Find a Number occurring odd number of times in a Given array

Objective: Given an array of integers, in which every element occurs even a number of times except one number which … Read more

## Convert Decimal into Irreducible Fraction

Objective: Given a decimal number, convert it into irreducible fraction. Irreducible Fraction : An irreducible fraction is a fraction in … Read more

## Delete X Nodes After Y Nodes In a Linked List

Objective: Given a Linked List and x and y. Delete x number of nodes after y nodes from the start. … Read more

## Get the Height of a Node in a Binary Tree

Objective: Given a binary tree, find the height of a given node in the tree.

Input: A Binary Tree and a node

Output: Height of a given node in the tree.

Example: Get The Height Of a Node

Approach:

Recursion:

## Reverse the binary representation of a number.

Objective: Write a program to Reverse the binary representation of a number Example: Input : 30 Output : 15 Explanation … Read more

## Check if one string is Rotation of another string

Objective: Write an algorithm to check if one string is Rotation of another string. This question has been asked in … Read more

## Print All Elements of Two Dimensional Array in Spiral

Objective: This question was asked in Amazon interview for the Software development Engineer position, Write an algorithm to print all the elements of two dimensional array in spiral.
Example :

Input: Two dimensional array

Output: All array elements printed in spiral.

Approach:

## Valid or Well Formed Parentheses | Part – 1

Objective: You have been asked to write an algorithm to find Whether Given the Sequence of parentheses is well-formed. This question was asked in the Amazon Interview.

Input: A String contains a sequence of parentheses

Output: true or false on whether parentheses are well-formed or not

Approach:

• Idea is to have two counters, one for open parentheses ‘{‘ and one for close ‘}’
• Read one character at a time and increment one of the counters
• If any given point of time count of close parentheses is greater than the open one, return false
• If at the end both counters are equal, return true

Example: { { } { } } – Well-formed

{ { } { = Not well-formed

Code: