Detail Form
We will send your result on your email id and phone no. please fill detail
Given two integers L and R, write a program that finds the count of numbers having prime number of set bits in their binary representation in the range [L, R].
Example 1:
Example 2:
Your Task:
You dont need to read input or print anything. Complete the function primeSetBits() which takes L and R as input parameter and returns the count of numbers having prime number of set bits in their binary representation.
Expected Time Complexity: O(nlog(n)sqrt(n))
Expected Auxiliary Space: O(1)
Constraints:
1 <= L <= R <=1000
Given a number N, print all its unique prime factors and their powers in N.
N = 100 Factor Power 2 2 5 2 N = 35 Factor Power 5 1 7 1
Input:
The first line of input contains an integer T denoting the number of test cases.The first line of each test case is N.
Output:
Print all prime factors and their powers separated by spaces. The output should be printed in increasing order of prime factors.
Constraints:
1 ≤ T ≤ 200
2 ≤ N ≤ 10000
Example:
Given a number N, the task is to find the largest prime factor of that number.
Example 1:
Example 2:
Your Task:
You don't need to read input or print anything. Your task is to complete the function largestPrimeFactor() which takes an integer N as input parameters and returns an integer, largest prime factor of N.
Expected Time Complexity: O(sqrt(N))
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 105
Given a sorted deck of cards numbered 1 to N.
1) We pick up 1 card and put it on the back of the deck.
2) Now, we pick up another card, it turns out to be card number 1, we put it outside the deck.
3) Now we pick up 2 cards and put it on the back of the deck.
4) Now, we pick up another card and it turns out to be card numbered 2, we put it outside the deck. ...
We perform this step until the last card.
If such an arrangement of decks is possible, output the arrangement, if it is not possible for a particular value of N then output -1.
Example 1:
Example 2:
Your Task:
You don't need to read input or print anything. Your task is to complete the function rotation() which takes the integer N as input parameters and returns If such arrangement of decks is possible, return the arrangement, if it is not possible for a particular value of n then return -1.
Expected Time Complexity: O(N^2)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 1000
You are provided an unlimited collection of red, green and blue balls. Now your task is to arrange N balls taken from this collection in a line in such a way that red balls appear first, followed by green balls and then blue balls. Given a value of N you have to find the number of ways to do that.
Note: In a particular arrangement a certain color of balls may be missing but the order must be strictly maintained with the available balls.
Example 1:
Example 2:
Your Task:
You don't need to read input or print anything. Your task is to complete the function numberOfWays() which takes an integer N and returns the number of ways to do that.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints
1<=N<=10^9