Posts

Words Starting with Upper Case

 Coding Problem Keys    Words Starting with Upper Case    Problem Statement  The program must accept a string S containing multiple words as the input. The program must print the words starting with an upper case alphabet in S as the output. If there is no such word, the program must print -1 as the output.  Input Format  The first line contains N. The second line contains N integers separated by a space.  Output Format  The first line contains the integer value(s) based on the given conditions.  Boundary Condition(s)  3 <= Length of S < 100  Example Input/Output 1   Input  How are you? I am FINE   Output  How I FINE  Explanation  The words starting with an upper case alphabets are How , I and FINE . Hence the output is How I FINE.  Example Input/Output 2   Input  Cricket Match 1: India vs Pakistan   Output  Cricket Match India Pakistan  Example...

Find Maxima/Minima

 Coding Problem Keys   Find Maxima/Minima   Problem Statement  Implement the following function: def MaximaOrMinima(a, b, c): Quadratic equation: A quadratic equation is any equation having the form, ax ² + bx + c, where 'a' cannot be zero. The function accepts coefficients of a quadratic equation, 'a', 'b' and 'c' as its argument. Implement the function to find the maximum or minimum value of quadratic equation by substituting integer values x, where -100 <= x <= 100. Return the values as follow: If a > 0, return the minimum value of the equation. If a < 0, return the maximum value of the equation. Assumption: a is not equal to zero. Note: Computed value lies within integer range.  Example 1   Input  a: 1 b: 2 c: 1  Output  0  Explanation  Since, (a > 0) output is the minimum value which is at x = -1, output = 1 * (-1) ²  + 2 * (-1) + 1 = 0. The custom input format for the above case: 1 2 1 (Th...

Matrix Print Excluding Border Elements

 Coding Problem Keys   Matrix Print Excluding Border Elements    Problem Statement  A matrix of size N*N is passed as input. The program must print the matrix excluding the elements present at the border of the matrix.  Boundary Condition(s)  3 <= N <= 100  Input Format  The first line contains the value of N . The next N lines contain N elements each separated by space(s).  Output Format  The first N-2 line contains the matrix without the border elements.  Example Input/Output 1   Input  3 1 2 3 4 5 6 7 8 9  Output  5  Example Input/Output 2   Input  5 33 56 23 88 29 384 388 392 58 30 93 63 272 223 75 95 338 44 87 90 94 22 21 67 43  Output  388 392 58 63 272 223 338 44 87  Note: Max Execution Time Limit: 5000 millisecs   Solution   Programming Language: C Language  #include <stdio.h> #include <stdlib.h> int main () ...

Reversed Sum of Pairs

 Coding Problem Keys   Reversed Sum of Pairs    Problem Statement  An array of N integers is passed as input. The program must print the sum of every two consecutive elements in the array from last.  Boundary Condition(s)  1 <= N <= 1000  Input Format  The first line contains N . The second line contains N integers separated by space(s).  Output Format  The first line contains the sum of pairs separated by a space.  Example Input/Output 1   Input  4 10 50 30 60  Output  90 60  Example Input/Output 2   Input  5 25 50 100 250 300  Output  550 150 25  Note: Max Execution Time Limit: 5000 millisecs   Solution   Programming Language: C Language  #include <stdio.h> #include <stdlib.h> int main () { int n,i; scanf( "%d" ,&n); int arr[n]; for ( int i= 0 ;i<n;i++){ scanf( "%d" ,&arr[...

Occurrences of Sub in Parent

 Coding Problem Keys   Occurrences of Sub in Parent   Problem Statement  You are given two strings containing only English letters. Write an algorithm to count the number of occurrences of the second string in the first string. (You may disregard the case of the letters).  Input  The first line of the input consists of a string parent, representing the first string. The second line consists of a string sub, representing the second string.  Output  Print an integer representing the number of occurrences of Sub in Parent. If no occurrence of Sub is found in Parent then print 0.  Example 1   Input  TimisplayinginthehouseofTimwiththetoysofTim Tim  Output  3  Explanation  Tim occurs 3 times in the first string, So, the output is 3.  Example 2   Input  abcdefg bcd  Output  1  Explanation  Tim occurs 1 times in the first string, So, the output is 1.  Solution...

Desktop Products

 Coding Problem Keys   Desktop Products   Problem Statement  A company DigiComparts manufactures 52 types of unique products for laptop and desktop computers. It manufactures 10 types of laptop products and 42 types of desktop products. Each product manufactured by the company has a unique productID from a-z and and A-Z. The laptop products have productIDs (a, i, e, o, u, A, I, E, O, U) while the rest of the productIDs are assigned to the desktop products. The company manager wishes to find the sales data for the desktop products. Given a list of productIDs of the sales of the last N products, write an algorithm to help the manager find the productIDs of the desktop products.  Input Format  The first line of the input consists of an integer numOfProducts, representing the number of products to be considered in the sales data (N). The second line consists of N space-separated characters - productID 1 , productID 2 , ... , productID N  represen...

Flowchart Logic 047

Image
 Coding Problem Keys   Flowchart Logic 047   Problem Statement  Please fill in the lines of code to implement the logic present in the flowchart.  Example Input/Output 1   Input  18 4 10  Output  1 2 11 13 14 16 17  Note: Max Execution Time Limit: 50 millisecs   Solution   Programming Language: Python 3 Language  N,X,Y= map ( int , input ().split()) ctr= 1 while (ctr<=N): if ((ctr<X or ctr>Y) and ctr% 3 != 0 ): print (ctr,end= " " ) ctr+= 1 # Published By PKJCODERS  Programming Language: C Language  #include <stdio.h> #include <stdlib.h> int main () { int N,X,Y; scanf( "%d%d%d" ,&N,&X,&Y); int ctr= 1 ; while (ctr<=N){ if ((ctr<X || ctr>Y) && ctr% 3 != 0 ){ printf( "%d " ,ctr); } ctr++; } } // Published By PKJCODERS  ( Note:  Inca...