
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++

263 Views
Suppose we have two numbers n and k. Amal and Bimal are playing a game. The rules are simple. Amal draws n sticks in a row. After that the players take turns crossing out exactly k sticks from left or right in each turn. Amal starts the game. If there are less than k sticks on the paper before some turn, the game ends. Amal wins if he makes strictly more moves than Bimal. We have to find who will be the winner.So, if the input is like n = 10; k = 4, then the output will be Bimal. ... Read More
C++ Program to count number of operations needed to place elements whose index is smaller than value

265 Views
Suppose we have an array A with n elements. We can perform these operations any number of times −Select any positive integer kSelect any position in the sequence and insert k into that positionSo, the sequence is changed, we proceed with this sequence in the next operation.We have to find minimum number of operations needed to satisfy the condition: A[i]

135 Views
Suppose we have an array A with n elements. We have to find the length of a non-empty subset of its elements such that their sum is even or return -1 when there is no such subset.So, if the input is like A = [1, 3, 7], then the output will be 2, because sum of [1, 3] is 4.StepsTo solve this, we will follow these steps −n := size of A for initialize i := 0, when i < n, update (increase i by 1), do: if A[i] mod 2 is same as 0, then: ... Read More

285 Views
Suppose we have two numbers n and k. Let we are trying to generate a string S with only three types of characters 'a', 'b' and 'c'. The maximum length of a substring of the string S that is a palindrome which does not exceeds k.So, if the input is like n = 3; k = 2, then the output will be "aab", because its length is 3 and the palindrome substring is "aa" with length at least 2. (other answers are also possible).StepsTo solve this, we will follow these steps −S := a blank string j := 0 for ... Read More

237 Views
Suppose we have a string S. S contains two types of characters in S, the 'x' and 'a'. We have to count what will be the longest string remaining after removal of few characters in S so that it becomes good string. A string is good if it has strictly more than the half of its length filled with character 'a'.So, if the input is like S = "xaxxxxa", then the output will be 3, because if we remove 4 'x's, the string will be "xaa" and this is a good string whose length is 3.StepsTo solve this, we will ... Read More

277 Views
Suppose we have four numbers n1, n2, k1 and k2. Consider there are 2 boxes, first one has n1 balls and second one has n2 balls. Amal and Bimal are playing the game. In one move they can take from 1 to k1 balls and throw them out, similarly second one will take 1 to k2 balls in his move. Amal starts the game and they plays alternatively. The one who cannot play his move will lose the game. We have to find who will be the winner.So, if the input is like n1 = 2; n2 = 2; k1 ... Read More

197 Views
Suppose we have a string S of length n, with only two types of characters, 'A' or 'P'. There are n students in a row, the ith student is angry if S[i] = 'A', if it is 'P' it says S[i] is patient. An angry student at index i will hit patient student in index i+1 in every minute, and for the last student even it he is angry, he cannot hit anyone. After hitting a patient student, that student also gets angry. We have to find the minimum minutes for after that no new students get angry.So, if the ... Read More

235 Views
Suppose we have two numbers n and k. We have unlimited number of coins worth values 1 to n. We want to take some values whose sum is k. We can select multiple same valued coins to get total sum k. We have to count the minimum number of coins needed to get the sum k.So, if the input is like n = 6; k = 16, then the output will be 3, because (2 * 6) + 4.StepsTo solve this, we will follow these steps −c := (n + k - 1) / n return cExampleLet us see the ... Read More

225 Views
Suppose we have two numbers n and k. We have to choose the maximum number of distinct elements from 1 to n, so that no subset whose sum is equal to k. If we can find then return the chosen numbers.So, if the input is like n = 5; k = 3, then the output will be [4, 5, 2]StepsTo solve this, we will follow these steps −for initialize i := (k + 1) / 2, when i

321 Views
Suppose we have five numbers s, v1, v2, t1 and t2. Amal and Bimal are playing a typing game, they are playing their game online. In this game they will type a string whose length is s. Amal types one character in v1 milliseconds and Bimal types one character in v2 milliseconds. Amal's network delay is t1 milliseconds, and Bimal's network delay is t2 milliseconds.If the connection delay is t milliseconds, the competition passes for a participant as follows −Exactly after t milliseconds after the game start the participant receives the text to be entered.Right after that he starts to ... Read More