Posts

Can you Guess ?

No problem statement. Find the logic from the given sample input/output. And answer Q queries. Constraints : 1 <= Value <= 100000 1<=nunber of query<=10000 SAMPLE INPUT   8 10 30 45 9 69 77 127 150 SAMPLE OUTPUT   8 42 33 4 27 19 1 222

GCD

Level  EASY Calculate and return GCD of two given numbers x and y. Numbers are within range of Integer. Input format : x and y (separated by space) Output format : GCD of x and y Sample Input 1: 20 5 Sample Output 1: 5 Sample Input 2: 96 14 Sample Output 2: 2

Reverse Level Order Traversal

Level MEDIUM Given a binary tree.Traverse the tree in the manner of reverse level order Example: 5 / \ 6 2 / \ 2 3 / \ 9 7 Reverse level order traversal for this tree is: 7 9 3 2 2 6 5 Input format : Line 1 : Elements in level order form (separated by space) (If any node does not have left or right child, take -1 in its place) Output Format : Print Reverse level order traversal Constraints : 1 <= N <= 10^5 Input: 5 6 2 2 3 -1 -1 9 7 -1 -1 -1 -1 Output : 7 9 3 2 2 6 5

B. Restore the Permutation by Merger

B. Restore the Permutation by Merger time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4,3,5,1,2], [3,2,1] are permutations, and [1,1], [0,1], [2,2,1,4] are not. There was a permutation p[1…n]. It was merged with itself. In other words, let's take two instances of p and insert elements of the second p into the first maintaining relative order of elements. The result is a sequence of the length 2n. For example, if p=[3,1,2] some possible results are: [3,1,2,3,1,2], [3,3,1,1,2,2], [3,1,3,1,2,2]. The following sequences are not possible results of a merging: [1,3,2,1,2,3], [3,1,2,3,2,1], [3,3,1,2,2,1]. For example, if p=[2,1] the possible results are: [2,2,1,1], [2,1,2,1]. The following sequences are not possible results of a merging: [1,1,2,2], [2,1,1,2], [1,2,2,1]. Your task is to restore t...

Popular posts from this blog

MySQL Multi Source Master Slave Replication using GTID

Setting Up PostgreSQL Logical Replication with Docker Compose

Regex 101: An Introduction to Regular Expressions for Developers