-
Fibonacci Pattern
Take N (number of rows), print the following pattern (for N = 4)0 1 1 2 3 5 8 13 21 34
Constraints:
0 < N < 100Explanation:
For given input n, You need to print n(n+1)/2 fibonacci numbers. Kth row contains , next k fibonacci numbers.
-
Series Printing
Take the following as input.A number (N1) A number (N2) Write a function which prints first N1 terms of the series 3n + 2 which are not multiples of N2.
Sample Input:
10 4
Sample Output:
5 11 14 17 23 26 29 35 38 41
Explanation:
The output will've N1 terms which are not divisible by N2.
- Reverse Sum
Given an integer, find the sum of the number and its reverse.
Example Input:
N = 536
Example Output:
1171
Explanation:
536 + 635 = 1171
- Armstrong Numbers
Given an integer, check whether it is an Armstrong Number. Armstrong number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers.
Sample Input: 153 Sample Output: Yes Explanation: 153 is an Armstrong Number because 153 = 13 + 53 + 33
- Perfect Numbers
You are given an integer A.
You have to print all the perfect numbers which lie in the range [1, A] in ascending order.
Perfect number is a positive integer which is equal to the sum of its proper positive divisors.
A proper divisor of a natural number is the divisor that is strictly less than the number.
Example Input:
Input 1:
8
Input 2:
35
Example Output:
Output 1:
6
Output 2:
6 28
-
Ganesha Pattern
Take as input N, an odd number (>=5) . Print the following pattern as given below for N = 7.* **** * * * * ******* * * * * **** *
Input Format: Enter value of N ( >=5 )
Constraints: N >= 5 Sample Input: 7 Sample Output:
* **** * * * * ******* * * * * **** *
Explanation: Catch the pattern for the corresponding input and print it accordingly.
-
Different Pattern
Given an integer N, print the corresponding Full Numeric Pyramid pattern for N.
For example if N = 5 then pattern will be like:
0 0 0 0 5 0 0 0 0 0 0 0 4 8 12 0 0 0 0 0 3 6 9 12 15 0 0 0 2 4 6 8 10 12 14 0 1 2 3 4 5 6 7 8 9
If the row are considered as i, the value of i for the top-most row will be N and then N-1, N-2, ...., 1 subsequently for remaining rows.
The values of pyramid are decided as i * (number of non-zero values printed before + 1).NOTE: There should be exactly one extra space after each
number
for each row.
Example Input:
3
Example Output:0 0 3 0 0 0 2 4 6 0 1 2 3 4 5
-
Hourglass Pattern
Take N as input: For N = 5, we wish to print the following pattern5 4 3 2 1 0 1 2 3 4 5 4 3 2 1 0 1 2 3 4 3 2 1 0 1 2 3 2 1 0 1 2 1 0 1 0 1 0 1 2 1 0 1 2 3 2 1 0 1 2 3 4 3 2 1 0 1 2 3 4 5 4 3 2 1 0 1 2 3 4 5
-
Check if sorted
Given an array, check if it sortedSample Input:
5 1 4 7 9 10
Sample Output:
YesExplanation:
The given array is sorted
-
Linear Search 2
Given an array containing duplicate numbers and a target value, find the index of 2nd occurence of the target value
Sample Input:6 9 2 8 2 4 2 2
Sample Output:
3
Explanation
Here target=2 There are 3 occurences of 2 in the given array. The 2nd occurence is found at index=3.
-
Super Maxima
Write a program to input N numbers from user and print the count of all the super maximas among them.
NOTE: An element is super maxima if there exist atleast one element before it and atleast one element after it and following conditions are satisfied:
- A[i-1] < A[i] > A[i+1]
- A[i-1] + A[i+1] < A[i]
Sample Input:
5 2 3 1 4 2
Sample Output:
1
Explanation:
Only 4 satisfies all the conditions, i.e. 4>1, 4>2 and 4>1+2.
-
String Addition
Jack is awesome. His friends call him little Einstein. To test him, his friends gave him a string. They told him to add the string with its reverse string and follow these rules:Every ith character of string will be added to every ith character of reverse string.
Both string will contain only lower case alphabets(a-z). Eg:- a+a=b,a+c=d,z+a=a (Refer to sample test cases for more details)
Input:
First line contains a value N denoting number of test cases. Next N lines contains string str.
Output:
For every string str output the string that Jack's friends wants from him.
Constraints
1 <= N <= 10
1 <= str <= 10^5
SAMPLE INPUT
4 hello codeapocalypse programming world
SAMPLE OUTPUT
wqxqw hhtdmqrrqmdthh wfxtebetxfw aajaa
-
Transpose Sum
Given a square matrix of size N, find its transpose and compute their sum.Sample Input:
2 1 9 2 6
Sample Output:
2 11 11 12
Explanation:
Transpose of the given matrix is1 2 9 6
Sum of original matrix and transpose matrix would be:
2 11 11 12
-
Determinant
Given a N*N matrix, find its determinant. Input contains N, size of the matrix in the first line. Next N lines contain each row of the matrix.
Sample Input:3 4 1 9 2 0 2 -1 8 -3
Sample Output:
84
-
Wave Print Column Wise
Take as input a two-d array. Wave print it column-wise.Input Format:
Two integers M(row) and N(colomn) and further M * N integers(2-d array numbers).Constraints:
Both M and N are between 1 to 10.Output Format:
All M * N integers seperated by commas with 'END' written in the end(as shown in example).Sample Input:
4 4 11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44
Sample Output:
11, 21, 31, 41, 42, 32, 22, 12, 13, 23, 33, 43, 44, 34, 24, 14, END
-
Factorial of GCD
Given two numbers, find their GCD and prints its factorial.
Sample Input
12 20
Sample Output
24Explanation
GCD(12,20) = 4 4! = 24
- GCD of N Numbers
Given N numbers, find and print their GCD.
Sample Input:5 20 40 100 55 35
Sample Output:
5