# Category: Oracle

## Separate 0’s and 1’s in a given array

Objec­tive:  Given an array which con­tains only 0’s and 1’s. write an algo­rithm to sep­a­rate 0’s and 1’s. Exam­ple int [] arrA = {1,0,1,0,1,1,0,0,0,0,1}; Out­put: [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]…

## Find the last repeating character in a given string.

Objec­tive: Given a string, write an algo­rithm to find the last repeat­ing char­ac­ter in it. Exam­ple: String input = “hori­zon tuto­ri­als” Out­put: ‘i’ String input = “algo­rithms” Out­put: No repeat­ing char­ac­ter found. Approach: Naive approach:…

## Dynamic Programming — Longest Common Subsequence

Objec­tive: Given two string sequences, write an algo­rithm to find the length of longest sub­se­quence present in both of them. These kind of dynamic pro­gram­ming ques­tions are very famous in the inter­views like Ama­zon, Microsoft,…

## Dynamic Programming — Rod Cutting Problem

Objec­tive: Given a rod of length n inches and a table of prices pi, i=1,2,…,n, write an algo­rithm to find the max­i­mum rev­enue rn obtain­able by cut­ting up the rod and sell­ing the pieces.…

## Dynamic Programming — Maximum size square sub-matrix with all 1s

Objec­tive: Given a matrix of 0’s and 1’s (binary matrix). Find out Max­i­mum size square sub-matrix with all 1’s. Exam­ple: Approach: Base Cases: If only one row is given then cells with 1’s will be…

## Backtracking — Search a Word In a Matrix

Objec­tive : Given a 2D matrix of char­ac­ters. Check whether the word exist in the matrix or not. If it exists then print its path. All move­ments are allowed (right, left, up, down and…

## Check if one string is Rotation of another string

Objec­tive: Write an algo­rithm to check if one string is Rota­tion of another string. This ques­tion has been asked in the Ama­zon inter­view. Exam­ple: Input Strings : ‘sum­it­jain’ and ‘tjain­sumi’ Out­put : true Input…