Posts

Binary - Case Sensitive Decryption

Binary - Case Sensitive Decryption  PROBLEM STATEMENT : The program must accept a string S representing an encrypted message as the input. The program must decrypt the string S and print the message based on the following conditions.  - The program must split the string S into substrings of equal length 5 .  - For each substring, the program must form a binary representation by replacing the lower case alphabets with 0 and the upper case alphabets with 1 .  Then the program must find the decimal equivalent of each binary representation and replace them with the characters as given below. From 0 to 25 -> a to z.  26 -> . (dot)  27 -> , (comma)  28 -> a SPACE character  29 -> ? (question mark symbol)  30 -> ' (single quote)  31 -> " (double quote)  Note: The string S contains only alphabets and its length is always a multiple of 5.  Boundary Condition(s):  1 <= Length of S <= 1000...

Alternate Sorting of Numbers

 Alternate Sorting of Numbers PROBLEM STATEMENT : Given an array of integers, rearrange the array in such a way that the first element is first maximum and second element is first minimum. The third element must be second maximum and fourth element must be second minimum and so on.  Input Format:  The first line will contain the numbers separated by a space.  Boundary Conditions:  Length of the input string will be from 3 to 200.  Output Format:   The numbers separated by a single space as per the mentioned conditions.  Example Input/Output 1: Input: ( ) 2 3 4 7 Output: 7 2 4 3 Example Input/Output 2: Input: ( ) 1 2 3 4 5 6 7 Output: 7 1 6 2 5 3 4 Example Input/Output 3: Input: ( ) 23 55 Output: 55 23 SOLUTION : C (Programming Language) Copy Code #include<stdio.h> #include<stdlib.h> int fun(const void *a,const void *b) { return (*(int*)a - *(int*)b); } int main() { int n=-1,a[201],i; while(scanf...

Modify Submatrices Diagonally

 Modify Submatrices Diagonally  PROBLEM STATEMENT : The program must accept an integer matrix of size R*C and an integer K as the input. The values of R and C are always divisible by K. The given R*C matrix contains only 0s and 1s. The program must form an alphabet matrix of size (R/K)*(C/K) starting from "a" being present in the bottom left corner. Then the program must modify the submatrices of size K*K diagonally. In each integer submatrix of size K*K, all 1s must be replaced with the related upper case alphabet in the alphabet matrix and all 0s must be replaced with the related lower case alphabet in the alphabet matrix. If "z" has reached while filling the alphabet matrix then "a" must be considered as the next alphabet in circular fashion while forming the alphabet matrix. Finally, the program must print the integer matrix replaced with the corresponding alphabets as the output.  Boundary Condition(s):   2 <= R, C <= 50  Input Format:   The fir...

Find Case Sensitive Pattern

 Find Case Sensitive Pattern  PROBLEM STATEMENT : The program must accept two string values S and P containing only alphabets as the input. The program must print all possible substrings of S that match the pattern P. If a substring matches the pattern P, then the case of each alphabet in the pattern P matches with the corresponding alphabet in the substring. The substrings must be printed in the order of their occurrence. If there is no such substring in S, then the program must print -1 as the output.  Boundary Condition(s):   1 <= Length of P <= Length of S <= 1000  Input Format:   The first line contains S.  The second line contains P.  Output Format:  The lines, each contains a substring matches the pattern P or the first line contains -1.  Example Input/Output 1: Input: ( ) SkillRack Do Output: Sk Ra Explanation:  Here the given pattern is Do.  The case of each alphabet in the pattern Do matches the subs...

Longest Substring Reverse Search

Longest Substring Reverse Search   PROBLEM STATEMENT : The program must accept two string values S1 and S2 as the input. The program must print the longest substring of S1 which occurs in S2 in reverse order as the output. If two or more such longest substrings occur in S1, then the program must print the first occurring substring as the output. If there is no such substring, then the program must print -1 as the output. Boundary Condition(s):    1 <= Length of S1, S2 <= 1000 Input Format:   The first line contains S1.  The second line contains S2. Output Format:   The first line contains the longest substring of S1 which occurs in S2 in reverse order.  Example Input/Output 1:   Input:   monkey  nomad  Output:  mon Explanation:   Here S1 = monkey and S2 = nomad.  The longest substring mon occurs in the string nomad in reverse order.  So mon is printed as the output.  Example Input/Output 2: Input: sk...

Matrix - Nine Submatrices

Matrix - Nine Submatrices  PROBLEM STATEMENT : The program must accept an integer matrix of size N*N as the input. The program must divide the given matrix into 9 submatrices based on the following conditions.  - The program must divide the given matrix into four submatrices of equal size.  - Then the program must divide the top-right submatrix horizontally into two submatrices of equal size.  - Then the program must divide the bottom-left submatrix vertically into two submatrices of equal size.  - Then the program must divide the bottom-right submatrix into four submatrices of equal size.  Finally, the program must print the sum of integers in each submatrix as the output.  Note: The value of N is always a multiple of 4.  Boundary Condition(s):   4 <= N <= 100  0 <= Matrix element value <= 1000  Input Format:   The first line contains N.  The next N lines, each contains N integers separated by a space. ...

Two Teams - Find the Winner

  Two Teams - Find the Winner  PROBLEM STATEMENT : There are two teams A and B playing a game. The game consists of N rounds. The points scored by both teams in N rounds are passed as the input to the program. The winner of the game is declared based on the following conditions.  - The team that wins more rounds than the other team is the winner of the game.  - If both teams win the same number of rounds, the team with the most points wins the game.  - If both teams win the same number of rounds and have the same number of points, then the result of the last round is considered.  The program must print the output based on the following conditions.  - If team A wins the game, then print the string value "Team A".  - If team B wins the game, then print the string value "Team B".  - If the result is a tie, then print the string value "TIE".  Boundary Condition(s):   1 <= N <= 100  Input Format:   The first line contains...