#### Category : arrays

I was trying to solve this problem but cannot come up with an optimized solution. Let’s say given array [2, 0] And another array of arrays [[3, 4], [0, 5], [1, 1], [4, 2], [3, 5]]. As per the question, the solution should be [[3, 4], [4, 2], [3, 5]] (Every first element is greater ..

I am unable to solve the errors in the program, like ‘::main’ must return ‘int’. Conversion from ‘Book*’ to non-scalar type ‘Book’ requested ‘clrscr’ was not declared in this scope. In this program I want to arrange the books alphabetically, But could not. #include <iostream> #include <string> using namespace std; class Book{ private : string ..

I implemented binary search in two ways and wondering which is more efficient? please help me know which is more efficient and how can it further be optimized? I am a beginner in programming. approach 1; #include<iostream> using namespace std; bool BinarySearch(int*a,int n,int s ){ if(n==1){ if(a[0]==s) return true; else return false; } else{ if(s<a[n/2]){ ..

I have a long byte array and I want to remove the lower nibble (the lower 4 bits) of every byte and move the rest together such that the result occupies half the space as the input. For example, if my input is 057ABC23, my output should be 07B2. My current approach looks like this: ..

I am given an array of positive integers. What are the minimum operations required such that the array becomes continuous. In one Operation we can Replace one number with any Integer. For e.g input: arr = [6,4,1,7,10], output: 2 we can make the array: [6,4,5,7,8] Source: Windows Que..

this is the question:Create an array of object to display the information of five batsmen.what i encountered is after compiling it displays same information 5 times how do i fix that. #include<iostream> using namespace std; class batsman{ private: string first_n; string last_n; int runs_made; int no_of_fours; int no_of_sixes; int i; //do i need to insert ..

So, I have a two dimensional array as follows: char board[3][3] = {{‘1’, ‘2’, ‘3’}, {‘4’, ‘5’, ‘6’}, {‘7’, ‘8’, ‘9’}}; and I’m accessing its elements in this way, for instance: cout << board[0][0] << board[0][1] << board[0][2] << "n"; cout << board[1][0] << board[1][1] << board[1][2] << "n"; cout << board[2][0] << board[2][1] << ..