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
Programming Articles - Page 650 of 3366
265 Views
Suppose we have an array A with n elements. There are n numbers written on a board. Amal and Bimal are playing a turn based game. In each turn, they select a number and remove it from board. Amal plays first. Amal wants to minimize the last number that he would left on the board, and Bimal wants to maximize it. We have to find the number which will remain on the board.So, if the input is like A = [2, 1, 3], then the output will be 2, because Amal will remove 3, Bimal will remove 1, so the ... Read More
316 Views
Suppose we have a number n. In a game, every character has four different health points (HP). The categories are as follows −Category A : If HP is in the form (4n + 1)Category B : If HP is in the form (4n + 3)Category C : If HP is in the form (4n + 2)Category D : If HP is in the form 4nThese 4 categories ordered from highest to lowest as A > B > C > D. So, category A is the highest and category D is the lowest. While playing the game, players can increase the ... Read More
92 Views
Suppose we have a string S with two kinds of letters 'S' and 'F'. If S[i] is 'S' we are at Seattle on ith day, and if it is 'F' we are at Florida. We have to check whether we flew more times from Seattle to Florida than Florida to Seattle.So, if the input is like S = "SSFFSFFSFF", then the output will be True.StepsTo solve this, we will follow these steps −n := size of S if S[0] is same as 'S' and S[n - 1] is same as 'F', then: return true Otherwise return falseExampleLet us ... Read More
285 Views
Suppose we have a number x. We have a six-faced dice and its faces are numbered from 2 to 7. We want exactly x points from the dice. When we throw the dice the face number will be added up to reach our target. We do not really care about the number of dice rolls, so we just want to know any number of rolls we can make to be able to get exactly x points for them. We are very lucky, so if the probability to get x points with chosen number of rolls is non-zero, we will be ... Read More
422 Views
Suppose we have a number n. We are going to find three numbers a, b and c, such that a + b + c = n and none of these three numbers are multiple of 3.So, if the input is like n = 233, then the output will be [77, 77, 79]StepsTo solve this, we will follow these steps −if (n - 2) mod 3 is same as 0, then: return 1, 2, and n - 3 Otherwise return 1, 1, and n - 2ExampleLet us see the following implementation to get better understanding −#include using namespace std; void solve(int n){ if ((n - 2) % 3 == 0) cout
330 Views
Suppose we have a string S with n lowercase letters. A string is called diverse if it has consecutive letters of the English alphabet and each letter occurs exactly once. (letters 'a' and 'z' are not adjacent). We have to check whether it is diverse or not.So, if the input is like S = "fced", then the output will be True.StepsTo solve this, we will follow these steps −sort the array S flag := 1 for initialize i := 1, when i < size of S and flag is non-zero, update (increase i by 1), do: if S[i] - ... Read More
266 Views
Suppose we have three numbers y, b and r. There are y yellow ornaments, b blue ornaments and r red ornaments for decoration. A decoration will be beautiful, if the number of blue ornaments used is greater by exactly 1 than the number of yellow ornaments, and the number of red ornaments used is greater by exactly 1 than the number of blue ornaments. We want to choose as many ornaments as possible and also want to make our decoration good. We have to find the maximum number of ornaments used for a beautiful decoration.So, if the input is like ... Read More
192 Views
Suppose we have a string S with n lowercase English letters. We have to reorder the characters in S, so that "trygub" is not a subsequence of the resulting string.So, if the input is like S = "pintontrygubabc", then the output will be "abbcginnoprttuy".StepsTo solve this, we will follow these steps −sort the array S return SExampleLet us see the following implementation to get better understanding −#include using namespace std; string solve(string S){ sort(S.begin(), S.end()); return S; } int main(){ string S = "pintontrygubabc"; cout
608 Views
In this article, we will explain maximum fruit count to make compote problem and implement a C++ program to solve it. The problem involves finding the maximum number of fruits that can be used to make a compote, given certain constraints. Let's break down the problem statement below. Maximum Fruit Count to Make Compote You are given a list of fruits, say a apples, b bananas, and c cherries, where a, b, and c are the counts of each type of fruit. Your task is to make a compote using these fruits such that the apples, bananas and cherries ... Read More