Maximum XOR value of two elements

Given an array of numbers find the maximum XOR value of two numbers in the array. Input Array = {12, 15, 5, 1, 7, 9, […]

Rectangles in a matrix

Given a character matrix in which some of the cells have alphabets written on them while other cells are empty (empty cells contains character ‘-‘ […]

Sum of rectangle region in a given matrix

Given a matrix of integers of order M*N and coordinates of a rectangular region in the matrix, write code to find the sum of all […]

Putting blocks at largest distance from each other in a row

Given a row (linear), two blocks are placed at each end and there are n empty positions between then. If ‘B’ represent block and n […]

Nearest number with non-decreasing digits

Given a number N given in the form of array, with each index storing one digit of the number. Write code to change the number […]

Flip all zeros to ones

Given a string of bits and a number k. In one flip, you can toggle k consecutive characters, how many flips are required to change the entire string […]

Print permutations of string replaced with digits

Given a string, print the variation of string as shown below Input String: ‘hat’ Replace one character with numeric one(‘1’): ‘1at‘, ‘h1t‘, ‘ha1‘ Replace two characters with […]

Check if two arrays are permutation of each other

Given two arrays of integers, write a code to check if one is permutation (arranging the same numbers differently) of elements present in the other. […]

Rearrange array into alternate positive and negative numbers

Given an array containing both positive and negative integers, write code to rearrange the elements so that positive and negative numbers comes alternately. If positive […]

Array implementation of Stack

A better implementation of Stack is usually using linked list unless you are sure of the number of elements in array. But if you are just starting […]