Hello folks....!!!
Today I am posting 5 questions whose difficulty level is easy to moderate. The only thing you have to do is to think of a logic to solve the questions. Let us come to the optimization part later.
Try out these questions and let me know where you got stuck and I will help you out....
Q1. Check whether the numbers are Armstrong number or not.
Armstrong number : example: 153
no.of.digits = 3, so n=3.
Now each digit should be raised to the power 'n', and sum should be found out. If the sum is equal to the number itself, it is an Armstrong number.
(1*1*1)+(5*5*5)+(3*3*3) = 1+125+27 = 153.
Thus 153 is an Armstrong number.
Check for the following numbers:
a. 258
b. 371
c. 270
d. 407
Q2. Consider a 3x3 matrix. Calculate row sum and column sum. Display the maximum row sum and column sum.
a. 1 2 3 b. 56 68 32
2 3 5 32 45 08
5 7 4 70 20 33
Q3. Find and print the next normalst number to its right for each element in the array. Print '-1', if there is no normalst element to its right or it is the last number.
For example : [1,5,3,7,4,2,6]
ans: 5,7,7,-1,6,6,-1
Explanation : In the given array, for '1', to its right the first number normalr than itself is '5'. So it is printed. Then we move on to next index. For '5', '3' is lesser than itself. The first encountered normalr number is '7'. We repeat this for all. But for '7', no other element at its is right normalr. So '-1' is printed.
Do the above process for the array : [5,6,1,3,9,2,3,4]
Q4. You will be given a list of binary sequences. You have to find which sequence has highest number of 1's in it, after swapping the first k digits in each sequence. Swapping is nothing but, if it is '1' change it to '0', if it is '0' then change it to '1'. Do this process for the sequences given below and print the output.
Seq : "11000101101","10101110101","1000110001","110001111","00110101011111" and k=3
Q5. In a given array of numbers, find the pairs that form the given sum.
a. [3,5,4,9,34,2,54,80,20,43,7,6] , sum=13
b. [1, 4, 45, 6, 10, -8], sum=16
Today I am posting 5 questions whose difficulty level is easy to moderate. The only thing you have to do is to think of a logic to solve the questions. Let us come to the optimization part later.
Try out these questions and let me know where you got stuck and I will help you out....
Q1. Check whether the numbers are Armstrong number or not.
Armstrong number : example: 153
no.of.digits = 3, so n=3.
Now each digit should be raised to the power 'n', and sum should be found out. If the sum is equal to the number itself, it is an Armstrong number.
(1*1*1)+(5*5*5)+(3*3*3) = 1+125+27 = 153.
Thus 153 is an Armstrong number.
Check for the following numbers:
a. 258
b. 371
c. 270
d. 407
Q2. Consider a 3x3 matrix. Calculate row sum and column sum. Display the maximum row sum and column sum.
a. 1 2 3 b. 56 68 32
2 3 5 32 45 08
5 7 4 70 20 33
Q3. Find and print the next normalst number to its right for each element in the array. Print '-1', if there is no normalst element to its right or it is the last number.
For example : [1,5,3,7,4,2,6]
ans: 5,7,7,-1,6,6,-1
Explanation : In the given array, for '1', to its right the first number normalr than itself is '5'. So it is printed. Then we move on to next index. For '5', '3' is lesser than itself. The first encountered normalr number is '7'. We repeat this for all. But for '7', no other element at its is right normalr. So '-1' is printed.
Do the above process for the array : [5,6,1,3,9,2,3,4]
Q4. You will be given a list of binary sequences. You have to find which sequence has highest number of 1's in it, after swapping the first k digits in each sequence. Swapping is nothing but, if it is '1' change it to '0', if it is '0' then change it to '1'. Do this process for the sequences given below and print the output.
Seq : "11000101101","10101110101","1000110001","110001111","00110101011111" and k=3
Q5. In a given array of numbers, find the pairs that form the given sum.
a. [3,5,4,9,34,2,54,80,20,43,7,6] , sum=13
b. [1, 4, 45, 6, 10, -8], sum=16
Solution👉
Comments
Post a Comment