Sunidhi Bansal has Published 1100 Articles

Count Magic squares in a grid in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 03-Aug-2020 09:29:29

212 Views

We are given with a matrix of numbers. The goal is to find the number of Magic squares present inside the given matrix.A Magic Square, if taken as a matrix, is a 3X3 matrix which contains the elements ranging from 1 to 9 just like a grid in Sudoku. Properties ... Read More

Maximize arr[j] – arr[i] + arr[l] – arr[k], such that i < j < k < l in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 28-Jul-2020 11:33:10

388 Views

We are given with an array of integers. The goal is to maximize the value of expression −arr[j]-arr[i] + arr[l]-arr[k] ; i

Maximize the value of x + y + z such that ax + by + cz = n in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 28-Jul-2020 11:30:49

263 Views

We are given with integers a, b, c, n. The goal is to maximize the sum of x, y and z such that ax+by+cz=n.From above formula, cz=n-(ax+by) z= (n- (ax+by))/cBy fixing x and y, calculate z using the above formula, for each x, y and z. Calculate sum and store ... Read More

Maximum mirrors which can transfer light from bottom to right in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 28-Jul-2020 11:28:57

60 Views

We are given with a square matrix which contains 0’s and 1’s only. 0 represents a blank or empty place and 1 means obstacle. We must find a number of mirrors that can be placed at empty cells such that these mirrors can transfer light from bottom to right. This ... Read More

Maximum number by concatenating every element in a rotation of an array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 28-Jul-2020 11:25:59

607 Views

We are given a circular array of numbers. A circular array is the one in which the elements are arranged such that the first element is treated as just next to the last element. These are used to implement queues.Each element has the same or different digit count. The goal ... Read More

Count no. of columns that are not sorted in increasing order in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 28-Jul-2020 11:24:04

182 Views

We are given an array of strings each of the same length. The goal is to find columns, ( matrix of strings ) that are not sorted in increasing order. For example, each first character in string is compared with the first character of the next string and so on ... Read More

Count minimum steps to get the given desired array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 28-Jul-2020 11:22:13

241 Views

We are given with an array target[] which has numbers in it. We must find the minimum steps in which array with all zeros [0, 0, 0, 0…] can be converted to target using following two operations only −Increment operation − all elements can be incremented by 1, each increment ... Read More

Count minimum right flips to set all values in an array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 28-Jul-2020 11:19:10

191 Views

We are given an array of 0s and 1s which represent the state of bulbs that are connected with the same wire in sequence. 0 represents that the bulb is OFF and 1 represents that the bulb is ON. For such a sequence of N bulbs, if the switch of ... Read More

Count minimum number of “move-to-front” moves to sort an array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 28-Jul-2020 11:17:26

962 Views

We are given with an array of numbers between 1 to n. The goal here is to find the no. of ‘move to front’ operations required to sort the given array. The array has no repetition. The ‘move to front’ operation picks an element and places at first position, here ... Read More

Count minimum bits to flip such that XOR of A and B equal to C in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 28-Jul-2020 11:16:37

278 Views

We are given with three binary sequences A, B and C of length N. Each sequence represents a binary number. We have to find no. of flips required of bits in A and B such that XOR of A and B results in C. A XOR B becomes C.First of ... Read More

Advertisements