1) Print the Pattern
Input :
M=5 N=4
Output:
1 6 11 16
2 7 12 17
3 8 13 18
4 9 14 19
5 10 15 20
2) Given Multiples of 4 print it is as a Square Matrix
Input :
N=12
Output:
1 2 3 4
12 5
11 6
10 9 8 7
Input :
N=16
Output:
1 2 3 4 5
16 6
15 7
14 8
13 12 11 10 9
3) Reorder the given 1-D array
Input:
N=3( Get an array of N*N size)
1 2 3
4 5 6
7 8 9
Output:
1 4 7
2 5 8
3 6 9
4)Reorder the given 1-D array
Input:
N=6 ( Get an array of N*N size)
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
19 20 21 22 23 24
25 26 27 28 29 30
31 32 33 34 35 36
Output:
1 7 13 18 12 6
2 8 14 17 11 5
3 9 15 16 10 4
33 27 21 22 28 34
32 26 20 23 29 35
31 25 19 24 30 26
Explanation:
1 2 3 1 7 13
7 8 9 ----> 2 8 14
13 14 15 3 9 15
4 5 6 18 12 6
10 11 12 ----> 17 11 5
16 17 18 16 10 4
5) Print the Pattern
Input :
N=5
Output:
5 4 1 2 3
10 9 6 7 8
15 14 11 12 13
20 19 16 17 18
25 24 21 22 23
6) Given an tray and coins each tray should have exactly one coin. The coins and the trays are equal
Input :
Tray size =8
Array = [ 0 , 3 , 2 , 0 , 0 , 0 , 0, 3 ]
Output:
First Coin Distribution : [ 1 , 2 , 2 , 0 , 0 , 0 , 0 , 3]
Second Coin Distribution : [1 , 1 , 2 , 1 , 0 , 0 , 0 , 3]
Third Coin Distribution : [1 , 1 , 1 , 1 , 1 , 0 , 0 , 3]
Fourth Coin Distribution : [1 , 1 , 1 , 1 , 1 , 0 , 1 , 2]
Fifth Coin Distibution : [1 , 1 , 1 , 1 , 1 , 1 , 1 , 1]
7) Find the missing number from 1 to n
Input :
N=10
Array ={2,4,3,1,5,7,10,9,8}
Output:
6
Input :
String 1 : Zohocorp
String 2: oc
Output:
Zhrp
The characters present in the String 2 remove it from String 1
8) Find the Largest possible sum considering only the Positive numbers and print the numbers
Input :
Array=[10,-3,-5,12,3,-5]
Output :
Sum = 15 , Numbers = 12,3
Input :
Array = [10,12,6,-5,30]
Output:
Sum=30 , Numbers =30.
9) Given two numbers find the sum
Input:
468
571
Output :
Sum = 8 + 1 Carry = 0,
Sum = 0 + 6 +7 Carry = 1,
Sum = 1 + 5 + 4 Carry =1,
Sum = 1 + 0 + 0 Carry =0,
Total Sum : 1039
10)Given a Sentence sort it based on the frequency of the sentence . If two words have same frequency sort it based on the ascending order.
Input :
Chandru is an hardworker and talented boy
Output:
Frequency : 7 2 2 10 3 8 3
Sorted : is an and boy Chandru talented hardworker
Ascending : an is and boy Chandru talented hardworker
No comments:
Post a Comment