Posts

Showing posts with the label Coding Problem Keys

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...

Pattern Printing - X to Y Forward and Reverse

 Coding Problem Keys   Pattern Printing - X to Y Forward and Reverse    Problem Statement  The program must accept the integers X and Y and print the pattern as shown in Example Input/Output.  Boundary Condition(s)  1 <= X, Y <= 100  Input Format  The first line contains X, Y each separated by a space .  Output Format  The pattern as explained in the Example Input/Output section.  Example Input/Output 1   Input  1 5  Output  12345 11345 11145 11115 12355 12555 15555  Example Input/Output 2   Input  3 9  Output  3456789 3356789 3336789 3333789 3333389 3333339 3456799 3456999 3459999 3499999 3999999  Note: Max Execution Time Limit: 5000 millisecs   Solution   Programming Language: Python 3 Language  x,y= map ( int , input ().split()) for i in range (x+ 1 ,y+ 1 ): for j in range (x,i): print (x,end= "" ) for j...

Bank Account Balance

 Coding Problem Keys   Bank Account Balance   Problem Statement  In a given month, N transactions related to a bank account are passed as the input along with the initial balance IB present in the bank account. The program must print the final balance FB in the account after all the N transactions have been completed. Each transaction has a code followed by the amount. The following are the possible codes and a code is classified either as credit or debit. CASH - Cash deposit in the account ( CREDIT ) ATM - Withdrawal using ATM ( DEBIT ) CHQ - Cheque deposit ( CREDIT ) CHQW - Payment made using a cheque to another entity ( DEBIT ) INT - Interest credited ( CREDIT ) MNT - Account Maintenance Charges ( DEBIT ) CARD - Purchase using Debit Card ( DEBIT ) ET - Electronic Transfer using NEFT/RTGS/IMPS etc If more than L ATM withdrawals are made in a month, then Rs. X is deducted for each withdrawal. If a card purchase is made for more than Rs. Y, then 10%...

Balloon Count Burst by Ath Kid

 Coding Problem Keys   Balloon Count Burst by Ath Kid   Problem Statement  There are N filled balloons each painted with a random number B(i) where i is from 1 to N and the balloons are tied up to a rope in a straight line. M kids who play football arrive and they decide to burst the balloons with the numbers divisible by their jersey numbers J(a) where a is from 1 to M. The program must print the count C of the balloons burst by the A-th Kid (1 <= A <= M).  Boundary Condition(s)  1 <= N <= 9999 1 <= M <= 20 1 <= A <= M  Input Format  The first line contains N, M, A each separated by a space . The second line contains N positive integers which denote the numbers on the balloons separated by a space. The third line contains M positive integers which denote the numbers on the jerseys separated by a space.  Output Format  The first line contains C.  Example Input/Output 1   Input  12 3 2...

Only One String Alphabets

 Coding Problem Keys   Only One String Alphabets   Problem Statement  N string values are passed as input to the program. Each string will contain only the alphabets a-z in lower case. A given alphabet may be repeated any number of times. The program must print the count C of the alphabets that are present only in one string value.  Boundary Condition(s)  2 <= N <= 500 1 <= Length of string value <= 1000  Input Format  The first line contains N. Next N lines contains the N string values.  Output Format  The first line contains Count C.  Example Input/Output 1   Input  3 mnppqqr ajkmnnm poormanagement  Output  7  Explanation  qtegjko are the 7 characters that are present only in one string value. q is present only in 1st string j & k are present only in 2nd string t e g o are present only in 3rd string  Note: Max Execution Time Limit: 5000 millisecs   Solutio...

Minimum Operations in Adjacent Elements

 Coding Problem Keys   Minimum Operations in Adjacent Elements   Problem Statement  You are given an array A of N distinct numbers. In one operation, you can choose two adjacent elements and remove the minimum one. Find the minimum number of operations needed to make the array in increasing order.  Input Format  The first line contains an integer, N, denoting the number of elements in A. Each line i of the N subsequent lines (where 0 <= i <= N) contains an integer describing A[i].  Output Format  The output prints the minimum number of operations needed to make the array to be in increasing order.  Constraints  1 <= N <= 10 ⁵ 1 <= A[i] <= 10 ⁹  Example Input/Output 1   Input  2 8 10  Output  0  Explanation  We don't have to remove any element as it is already in increasing order.  Example Input/Output 2   Input  3 10 3 4  Output  2  Not...