
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

633 Views
We are given N rupees. The goal is to buy maximum water possible with the money where the rates of water bottles are as follows −Plastic Bottles: A Rupees for 1 litreGlass Bottles: B Rupees for 1 litreGlass Bottles: B Rupees for 1 litreNow the original cost of glass bottles becomes B-E rupees. After returning.If the cost of plastic bottles is still less than B-E, then only buy plastic bottles. Else buy N-E/B-E glass bottles and spend rest on plastic bottles.InputN = 6, A = 5, B = 4, E = 3;OutputMaximum litres of water: 3Explanation − B-E=1, 1A n/a= ... Read More

139 Views
We are given an array of numbers say Arr1[] and another array Arr2[] of same or different length. The Arr1[] has elements sorted in ascending order, such that a single element is unsorted. We must find the element from the second array Arr2[] such that it can replace the wrongly placed element of Arr1[] and make it sorted. Also, the element chosen from Arr2[] should be maximum if there are multiple options available.InputArr1[]= { 1,3,5,7,2,11 }, Arr2[]= { 4,8,7,10,9 }OutputMaximum element that can make Arr1 sorted: 10Explanation − Numbers in Arr2[] that can make Arr1[] sorted − 8,9,10 as they all are >=7 and =12 and

2K+ Views
Turing Machine − A Turing machine is a device used to accept words of a language generated by type 0 grammars. A Turing Machine (TM) is a mathematical model which consists of an infinite length tape divided into cells on which input is given. It consists of a head which reads the input tape. A state register stores the state of the Turing machine. After reading an input symbol, it is replaced with another symbol, its internal state is changed, and it moves from one cell to the right or left. If the TM reaches the final state, the input ... Read More

331 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 are −All numbers occur exactly once.Sum of all 9 cells in the matrix is 45.Sum of each row of 3 is 15.Sum of each column of 3 is 15.Sum of diagonals of 3 is 5.To get such sums, 5 is always in the middle of both diagonals.Inputint arr[][]= { { ... Read More

371 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 the maximum such sum obtained.Inputn = 6, a = 3, b = 4, c = 5;Outputmaximum x+y+z is 2.Explanation − for x=2, y=0 and z=0 ax+by+cz=n.3*2+0*4+0*5=6 = nInputn = 4, a = 3, b = 1, c = 2;Outputmaximum x+y+z=4Explanation − for x=0, y=4 and z=4 ax+by+cz=n.0*3+4*1+0*2=4 = nApproach used ... Read More

219 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 is possible when, mirror is placed at index [i, j] and for all cells on the right in that particular row ( i ) and cells in the bottom ( j ) in that particular column have no obstacle.If the mirror is at A[i][j], then all A[i+1 to n][ j ... Read More

744 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 is to create the highest number possible by concatenating the numbers, using rotation of elements if required. We will do this by finding the highest leftmost digit among all the leftmost digits of all elements. The number with the highest leftmost digit will take the first place.If it is at ... Read More

258 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 till the last string. If they are not in increasing order, increase the count. Do this for all second characters, then third characters of all strings and so on till the last character.InputArr[]= { “abc”, “bcd”, “def” }OutputCount of columns: 0Explanation − for each column,Column 1: character at index 0 : a

371 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 operation can be counted individually in steps. ( for n increments in n elements steps=n )Doubling operation − the whole array is doubled. For all elements it is counted once. ( each doubling operation doubles all elements’ value, count it as 1 in stepsThe goal is to find the minimum ... Read More