Tip 1 : Practise 5 problems daily from websites like hackerrank, codechef, codeforces
Tip 2 : Participate in codechef, codeforces contest.
Tip 3 : Attend mock interviews and should have good communication skills.
Tip 1 : Maintain atleast 2 different projects, write powerful summary statement.
Tip 2 : Maintain skills relevant to job description, include relevant experience.
You are given an integer ‘A’. Your task is to find the greatest non-negative integer whose square is less than or equal to ‘A’.
Square of a number is the product of the number with itself. For e.g. square of 3 is 9.
Input Format
The first line of input contains an integer ‘T’ denoting the number of test cases to run. Then the test cases follow.
The first line of each test case contains a single integer ‘A’.
Output Format
For each test case, print the greatest positive integer whose square is less than or equal to ‘A’.
Print the output of each test case in a separated line.
Note
You do not need to print anything; it has already been taken care of. Just implement the given function.
The lowest common ancestor (LCA) is a concept in graph theory and computer science.
Let ‘T’ be a rooted tree with ‘N’ nodes. The lowest common ancestor is defined between two nodes, ‘u’ and ‘v’, as the lowest node in ‘T’ that has both ‘u’ and ‘v’ as descendants (where we allow a node to be a descendant of itself). - Wikipedia
For the given tree, The LCA of nodes 5 and 8 will be node 2, as node 2 is the first node that lies in the path from node 5 to root node 1 and from node 8 to root node 1.
Path from node 5 to root node looks like 5 → 2 → 1.
Path from node 8 to root node looks like 8 → 6 → 2 → 1.
Since 2 is the first node that lies in both paths. Hence LCA will be 2.
Given any two nodes ‘u’ and ‘v’, find the LCA for the two nodes in the given Tree ‘T’.
Note: For each test case, the tree is rooted at node 1.
1. The sizes will range from 1 to ‘N’ and will be integers.
2. The sum of the pieces cut should be equal to ‘N’.
3. Consider 1-based indexing.
Ninja is a poor but an intelligent boy. He has a rod of length ‘N’ units. He wants to earn maximum money by selling this rod in the market. So he cuts the rod into different sizes and each size has a cost associated with it. Determine the maximum money he can earn by cutting the rod and selling its pieces.
If 'ARR1' = [0, 2, 1], and 'ARR2' = [8, 10, 4] then the most optimal pairing will be (0, 4) , (1, 8) and (2, 10). The sum of absolute difference will be 4 + 7 + 8 = 19.
An element from one array can make a pair only with at most one element of another array.
You have been given two arrays/lists 'ARR1' and 'ARR2' of length 'N'. Your task is to pair each element of 'ARR1' to an element of 'ARR2' such that the sum of the absolute difference of all pairs is minimum.
Example:
If 'ARR1' = [0, 2, 1], and 'ARR2' = [8, 10, 4] then the most optimal pairing will be (0, 4) , (1, 8) and (2, 10). The sum of absolute difference will be 4 + 7 + 8 = 19.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is 3 + 2 * 4 based on operator precedence?