
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 26504 Articles for Server Side Programming

208 Views
Problem statementGiven n wines in a row, with integers denoting the cost of each wine respectively. Each year you can sale the first or the last wine in the row. The price of wines increases over time. Let the initial profits from the wines be P1, P2, P3…Pn. On the Yth year, the profit from the ith wine will be Y*Pi. For each year, your task is to print start or end denoting whether first or last wine should be sold. Also, calculate the maximum profit from all the wines.ExampleIf wine prices are {2, 4, 6, 2, 5} then output ... Read More

188 Views
In this problem, we are given a number n. Our task is to find the maximum count of primes whose sum is equal to given N.Here, we will find the maximum number of prime numbers that when added will be equal to the number.The prime number are those number which can be divide by either themselves or one.let's take an example to understand the problem −Input − N = 9Output − 4Explanation −9 can be repressed as the sum of prime numbers in the following ways: 2, 2, 2, 3 3, 3, 3 2, 2, 5 2, 7 Out of ... Read More

723 Views
Problem statementGiven an array of n integers and q queries, each query having a range from l to r. Find the maximum prefix-sum for the range l – r.ExampleIf input array is arr[] = {-1, 2, 3, -5} and queries = 2 and ranges are: l = 0, r = 3 l = 1, r = 3 then output will be 4 and 5.The range (0, 3) in the 1st query has [-1, 2, 3, -5], since it is prefix, we have to start from -1. Hence, the max prefix sum will be -1 + 2 + 3 = 4The ... Read More

407 Views
In this problem, we are given two arrays A and B of n elements each. Our task is to create a program to find the maximum possible XOR of every element in an array with another array.We have to compute the maximum XOR for each element of array A with array B i.e. for each element of array A we will select an element in array B which will have the maximum XOR value.Let's take an example to understand the problem −Input −array A = {3, 6 ,11, 9} array B = {8, 2, 4, 1}Output −11 14 15 13Explanation−Let’s ... Read More

314 Views
Problem statementGiven an Array of non-negative integers. Find out three elements from the array which form a triangle of maximum perimeterExampleIf input array is {5, 1, 3, 5, 7, 4} then maximum perimeter is (7 + 5 + 5) = 17AlgorithmSort the array in non-increasing order. So, the first element will be maximum and the last will be minimumIf the first 3 elements of this sorted array forms a triangle, then it will be the maximum perimeter triangleExample Live Demo#include using namespace std; int getMaxPerimeter(int *arr, int n) { sort(arr, arr + n, greater()); int maxPerimeter = 0; ... Read More

777 Views
In this problem, we are given a 2D matrix of size M*N. Our task is to create a program that will find the maximum path sum in the matrix.Here, the maximum path sum in the matrix is defined as the sum of all elements for one row to the last row. The allowed moves for traversing the path are downward move and diagonal move. The start and endpoints can be any element of the first and last row of the matrix respectively.Let's take an example to understand the problemInput −matrix [][] = 3 5 9 1 7 2 ... Read More

320 Views
Given with an array and the task is to find the number of odd and even elements in an array using standard template library in C++.To solve this problem we are using the function count_if() present in C++ standard template library. What is a count_if() function?Syntaxcount_if(LowerBound, UpperBound, function)Description − This function returns the number of elements in an array that satisfies the given condition. It takes three parameters.Lower Bound − It points to the first element of an array or any other sequence.Upper Bound − It points to the last element of an array or any other sequence.Function − It ... Read More

247 Views
Given with an array and the task is to find the number which are divisible by N using standard template library in C++.To solve this problem we are using the function count_if() present in C++ standard template library.What is a count_if() function?Syntaxcount_if(LowerBound, UpperBound, function)Description − This function returns the number of elements in an array that satisfies the given condition. It takes three parameters.Lower Bound − It points to the first element of an array or any other sequence.Upper Bound − It points to the last element of an array or any other sequence.Function − It returns the Boolean value ... Read More

346 Views
Isprint() in C++ is inbuilt function in “cctype.h” header file which checks whether the character is printable or not.Isprint returns true for constant cases as Isprint aside from the house character (' '), that returns true.A locale-specific model version of this function (Isprint) exists in cctype header file.-Isprint() function can be used to check any Non-Printing character in a series of sentences.-Isprint() is an Inbuilt function that provides efficient way to handle non printing characters-Isprint() helps to minimize the lines of code for programmer.-Isprint() is in true sense decreases the compilation time of program.Including cctype.h in your program not only ... Read More

209 Views
Given is the task to show the working of forward_list::emplace_after() and forward_list::emplace_front() functions in c++.A forward_list only keeps linkage with the next element unlike normal list that keeps linkage with the next as well as the preceding elements, which helps iterations in both directions. But forward_list can only iterate in the forward direction.The forward_list::emplace_after() and forward_list::emplace_front() functions are a part of the c++ standard library.The forward_list::emplace_after() function is used to insert a new element inside a list after the element whose position is specified inside the argumentThe forward_list::emplace_front() function is used to insert an element in the beginning of the ... Read More