Category Archives: Mathematical

Pythagorean Triplet in an array using STL

Given an array of integers, write a function that returns true if there is a triplet (a, b, c) that satisfies a2+b2=c2 Example: Input: arr[] = {8, 1, 4, 6, 10} Output: True There is a Pythagorean triplet (8, 6, 10). Input: arr[] = {1, 2, 4, 3} Output: False There is no Pythagorean triplet. Approach: The problem… Read More »

Person left at the end

Given the value of N which represents the number of people standing in the queue, Each person has an id equivalent to their position. Now from this queue, the people who are at even locations are removed and made a separate queue. This process continues till 1 person left. The task is to determine the id of the… Read More »

Nth number whose sum of digits is 10

Given, write a program that prints the Nth number whose sum of digits is 10. Examples: Input : 2 Output : 28 Explanation : the first number is 19, whose digit sum is 10. Input : 5 Output : 55 Explanation : the first four numbers whose digit sum is 10 are 19,28,37,46. Approach: In order to obtain… Read More »