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
Server Side Programming Articles - Page 1684 of 2646
219 Views
In this problem, we are given a string str and Q queries consisting of two values a and b. Our task is to create a program to solve Queries for characters in a repeated string in C++.Problem DescriptionTo solve each query, we need to check whether the characters at index a and b are the same and return the value accordingly.Let’s take an example to understand the problem, Input: str = “tutorialspoint”Q = 2Query = {{0, 2}, {4, 7}}Output:RepeatedNot RepeatedExplanationFor Query 1, the character at index 0 is t, and the character at index 2 is t. Both are the ... Read More
134 Views
In this tutorial, we will be discussing a program to find maximum value with the choice of either dividing or considering as it is.For this we will be provided with an integer value. Our task is to find the maximum value with either by dividing the number into four parts recursively or choosing it as it is using the given function F(n) = max( (F(n/2) + F(n/3) + F(n/4) + F(n/5)), n).Example Live Demo#include using namespace std; //calculating the maximum result int findMaximum(int size) { int term[size + 1]; term[0] = 0; term[1] = 1; int i=2; while(i
287 Views
In this problem, we are given an array arr[] and a number M. Our task is to create a program to calculate the Maximum Weight Difference in C++.Problem StatementWe will find M elements from the array such that the absolute difference between the sum and the sum of rest elements is maximum.Let’s take an example to understand the problem, Input: arr[] = {3, 1, 6, 9, 4} M = 3Ouput:15ExplanationWe will consider 4, 6, 9. The sum is 19. The absolute difference with the sum of rest numbers is|19 - 4| = 15Solution ApproachThe solution to the problem is based ... Read More
261 Views
In this problem, we need to create a program to find Maximum value of an integer for which factorial can be calculated on a machine in C++.Factorial of a number is a huge value, as it is the product of all values preceding it. And C++ can handle large values only upto a certain value by using its inbuilt function. We need to find this restriction.Solution ApproachWe will simply use the property of data types which is when the numbers exceed the maximum value a negative number is returned.We will use long long int which is the largest basic data ... Read More
352 Views
In this problem, we are given an array arr. Our task is to create a program to find the Maximum value K such that the array has at-least K elements that are >= K in C++.Problem DescriptionWe need to find a value K, that fulfills the condition that there are K or more elements in the array that are greater than or equal to K.Let’s take an example to understand the problem, Input:arr[] = {3, 5, 1, 7, 6, 6, 4, 8}Output:5ExplanationElements in the array that are greater than or equal to 5: 5, 6, 6, 7, 8.Solution ApproachA simple ... Read More
311 Views
In this problem, we are given an array arr[] of N elements initialized with 0. Our task is to create a program to find the Maximum value in an array after m range increment operations in C++.Problem DescriptionOn the array, we will perform m range increment operation of the type, update[L, R, K] = Add value K, to all elements in the range.After performing m operations on the array. We need to find the element with maximum value in the array.Let’s take an example to understand the problem, InputN = 6, m = 4 Update[][] = {{1, 4, 12}, {0, ... Read More
342 Views
In this problem, we are given a number N denoting the number of platforms a station has with two tracks each. And T trains will be passing the station whose arrival and departure time are given. Each train stops at a specific station. Our task is to create a program to find the Maximum trains for which stoppage can be provided in C++.Let’s take an example to understand the problem, InputN = 3, T = 5 Trains = {{0915, 0930, 2}, {0930, 0945, 1}, {0930, 1200, 1}, {0910, 0925, 3}, {0940, 1015, 1}}Output4ExplanationThe train schedules are, Train 1: Train will ... Read More
387 Views
In this problem, we are given a two-dimensional array arr[][]. Our task is to create a program to find the Maximum trace possible for any sub-matrix of the given matrix in C++.Problem Descriptionwe need to find the maximum trace for any sub-matrix. The trace is the sum of elements of the main diagonal of the matrix.Let’s take an example to understand the problem, Inputarr[][] ={{-2, 5, 3}, {1, 6, 2}, {4, 3, 9}}Output15ExplanationFor the sub-array: {1, 6} {9, 3}Solution ApproachA simple solution is to find the max sum using the ... Read More
235 Views
In this problem, we are given an array arr[]. Our task is to create a program to find the Maximum sum such that no two elements are adjacent in C++.Problem DescriptionWe need to find the maximum sum of the sequence from the array such that no 2 numbers from the sum sequence are adjacent in the array.Let’s take an example to understand the problem, Inputarr[] = {5, 1, 3, 7, 9, 2, 5}Output22ExplanationTaking sum sequence from index 0 with alternate elements : 5 + 3 + 9 + 5 = 22 Taking sum sequence from index 1 with alternate elements ... Read More
269 Views
In this problem, we are given an array arr[]. Our task is to create a program to find the Maximum sum such that no two elements are adjacent in C++.Problem DescriptionWe need to find the maximum sum of the sequence from the array such that no 2 numbers from the sum sequence are adjacent in the array.Let’s take an example to understand the problem, Inputarr[] = {5, 1, 3, 7, 9, 2, 5}Output22ExplanationTaking sum sequence from index 0 with alternate elements : 5 + 3 + 9 + 5 = 22 Taking sum sequence from index 1 with alternate elements ... Read More