
25 15
100
59 ?
Answer is 1
Sum of all 4 outer box is 100
25 15
100
59 ?
Sum of all 4 outer box is 100
IF 1 + 1 = 5
2 + 2 = 20
3 + 3 = 45
Then, 4 + 4 = ?
How?
Multiply the two numbers and then multiply the result by 5.
16, 43, 27
11, 36, 25
29, 56, ?
How?
Number in middle column is sum of the respective numbers in first and third column. thus the missing number should be 56 – 29 = 27.
Problem Statement:
Given an array a of n integers find all possible Pythagorean triplets from the array.
A Pythagorean triple consists of three positive integers a, b, and c, such that a2 + b2 = c2. this formula is derived from Pythagoras theorem: “For every right angle triangle with side lengths a, b, and c=> a2 + b2 = c2“.
Pythagorean Triplet
Solution:
[Read more…]
IF 1 = 3
2 = 6
3 = 9
4 = 12
Then, 5 = ?
How?
Its simple, just multiply the number by 3.
IF 1+2 = 3
3 + 4 = 21
5 + 6 = 55
Then 4 + 5 = ?
Explanation:
1 + 2 => (1)^2 + (1*2) = 3
3 + 4 => (3)^2 + (3*4) = 21
5 + 6 => (5)^2 + (5*6) = 55
Thus 4 + 5 => (4)^2 + (4*5) = 36
Problem Statement:
Given a set S of n integers find all possible subsets(a,b,c) such that a + b + c = 0.
Solution:
Brute force approach is of O(n^4) but we can solve it in O(n^2) by using the approach in Non duplicate pairs that sum to S.
First sort the array(Order O(nlogn)), than finding a, b, c pairs is equal to finding=> For every element a in the array, if there exists a pair with sum equal to -a. As explained in Non duplicate pairs that sum to S, we can get the pair with sum -a in O(n) and we have to repeat this exercise n times so order of complexity will be O(n^2).
13, 25, ?
16, 28, 35
19, 31, 28
What is the missing number.
How?
If you see the rows every next number = previous number in the row +3.
Whats the missing number in the triangle