|
| 1 | +1. |
| 2 | + Problem Statement – An automobile company manufactures both a two wheeler (TW) and a four wheeler (FW). A company manager wants to make the production of both types of vehicle according to the given data below: |
| 3 | + |
| 4 | + 1st data, Total number of vehicle (two-wheeler + four-wheeler)=v |
| 5 | + 2nd data, Total number of wheels = W |
| 6 | + The task is to find how many two-wheelers as well as four-wheelers need to manufacture as per the given data. |
| 7 | + Example : |
| 8 | + |
| 9 | + Input : |
| 10 | + 200 -> Value of V |
| 11 | + 540 -> Value of W |
| 12 | + |
| 13 | + Output : |
| 14 | + TW =130 FW=70 |
| 15 | + |
| 16 | + Explanation: |
| 17 | + 130+70 = 200 vehicles |
| 18 | + (70*4)+(130*2)= 540 wheels |
| 19 | + |
| 20 | + Constraints : |
| 21 | + |
| 22 | + 2<=W |
| 23 | + W%2=0 |
| 24 | + V<W |
| 25 | + Print “INVALID INPUT” , if inputs did not meet the constraints. |
| 26 | + |
| 27 | + The input format for testing |
| 28 | + The candidate has to write the code to accept two positive numbers separated by a new line. |
| 29 | + |
| 30 | + First Input line – Accept value of V. |
| 31 | + Second Input line- Accept value for W. |
| 32 | + The output format for testing |
| 33 | + |
| 34 | + Written program code should generate two outputs, each separated by a single space character(see the example) |
| 35 | + Additional messages in the output will result in the failure of test case |
| 36 | + |
| 37 | +2. |
| 38 | + Problem Statement – Given a string S(input consisting) of ‘*’ and ‘#’. The length of the string is variable. The task is to find the minimum number of ‘*’ or ‘#’ to make it a valid string. The string is considered valid if the number of ‘*’ and ‘#’ are equal. The ‘*’ and ‘#’ can be at any position in the string. |
| 39 | + Note : The output will be a positive or negative integer based on number of ‘*’ and ‘#’ in the input string. |
| 40 | + |
| 41 | + (*>#): positive integer |
| 42 | + (#>*): negative integer |
| 43 | + (#=*): 0 |
| 44 | + Example 1: |
| 45 | + Input 1: |
| 46 | + |
| 47 | + ###*** -> Value of S |
| 48 | + Output : |
| 49 | + |
| 50 | + 0 → number of * and # are equal |
| 51 | + |
| 52 | +3. |
| 53 | + Given an integer array Arr of size N the task is to find the count of elements whose value is greater than all of its prior elements. |
| 54 | + |
| 55 | + Note : 1st element of the array should be considered in the count of the result. |
| 56 | + |
| 57 | + For example, |
| 58 | + Arr[]={7,4,8,2,9} |
| 59 | + As 7 is the first element, it will consider in the result. |
| 60 | + 8 and 9 are also the elements that are greater than all of its previous elements. |
| 61 | + Since total of 3 elements is present in the array that meets the condition. |
| 62 | + Hence the output = 3. |
| 63 | + Example 1: |
| 64 | + |
| 65 | + Input |
| 66 | + 5 -> Value of N, represents size of Arr |
| 67 | + 7-> Value of Arr[0] |
| 68 | + 4 -> Value of Arr[1] |
| 69 | + 8-> Value of Arr[2] |
| 70 | + 2-> Value of Arr[3] |
| 71 | + 9-> Value of Arr[4] |
| 72 | + |
| 73 | + Output : |
| 74 | + 3 |
| 75 | + |
| 76 | + Example 2: |
| 77 | + 5 -> Value of N, represents size of Arr |
| 78 | + 3 -> Value of Arr[0] |
| 79 | + 4 -> Value of Arr[1] |
| 80 | + 5 -> Value of Arr[2] |
| 81 | + 8 -> Value of Arr[3] |
| 82 | + 9 -> Value of Arr[4] |
| 83 | + |
| 84 | + Output : |
| 85 | + 5 |
| 86 | + |
| 87 | + Constraints |
| 88 | + |
| 89 | + 1<=N<=20 |
| 90 | + 1<=Arr[i]<=10000 |
| 91 | + |
| 92 | +4. |
| 93 | + A parking lot in a mall has RxC number of parking spaces. Each parking space will either be empty(0) or full(1). The status (0/1) of a parking space is represented as the element of the matrix. The task is to find index of the prpeinzta row(R) in the parking lot that has the most of the parking spaces full(1). |
| 94 | + |
| 95 | + Note : |
| 96 | + RxC- Size of the matrix |
| 97 | + Elements of the matrix M should be only 0 or 1. |
| 98 | + |
| 99 | + Example 1: |
| 100 | + Input : |
| 101 | + 3 -> Value of R(row) |
| 102 | + 3 -> value of C(column) |
| 103 | + [0 1 0 1 1 0 1 1 1] -> Elements of the array M[R][C] where each element is separated by new line. |
| 104 | + Output : |
| 105 | + 3 -> Row 3 has maximum number of 1’s |
| 106 | + |
| 107 | + Example 2: |
| 108 | + input : |
| 109 | + 4 -> Value of R(row) |
| 110 | + 3 -> Value of C(column) |
| 111 | + [0 1 0 1 1 0 1 0 1 1 1 1] -> Elements of the array M[R][C] |
| 112 | + Output : |
| 113 | + 4 -> Row 4 has maximum number of 1’s |
| 114 | + |
| 115 | +5. |
| 116 | + A party has been organised on cruise. The party is organised for a limited time(T). The number of guests entering (E[i]) and leaving (L[i]) the party at every hour is represented as elements of the array. The task is to find the maximum number of guests present on the cruise at any given instance within T hours. |
| 117 | + |
| 118 | + Example 1: |
| 119 | + Input : |
| 120 | + |
| 121 | + 5 -> Value of T |
| 122 | + [7,0,5,1,3] -> E[], Element of E[0] to E[N-1], where input each element is separated by new line |
| 123 | + [1,2,1,3,4] -> L[], Element of L[0] to L[N-1], while input each element is separate by new line. |
| 124 | + Output : |
| 125 | + 8 -> Maximum number of guests on cruise at an instance. |
| 126 | + |
| 127 | + Explanation: |
| 128 | + |
| 129 | + 1st hour: |
| 130 | + Entry : 7 Exit: 1 |
| 131 | + No. of guests on ship : 6 |
| 132 | + |
| 133 | + 2nd hour : |
| 134 | + Entry : 0 Exit : 2 |
| 135 | + No. of guests on ship : 6-2=4 |
| 136 | + |
| 137 | + Hour 3: |
| 138 | + Entry: 5 Exit: 1 |
| 139 | + No. of guests on ship : 4+5-1=8 |
| 140 | + |
| 141 | + Hour 4: |
| 142 | + Entry : 1 Exit : 3 |
| 143 | + No. of guests on ship : 8+1-3=6 |
| 144 | + |
| 145 | + Hour 5: |
| 146 | + Entry : 3 Exit: 4 |
| 147 | + No. of guests on ship: 6+3-4=5 |
| 148 | + Hence, the maximum number of guests within 5 hours is 8. |
| 149 | + |
| 150 | + Example 2: |
| 151 | + Input: |
| 152 | + 4 -> Value of T |
| 153 | + [3,5,2,0] -> E[], Element of E[0] to E[N-1], where input each element is separated by new line. |
| 154 | + [0,2,4,4] -> L[], Element of L[0] to L[N-1], while input each element in separated by new line |
| 155 | + |
| 156 | + Output: |
| 157 | + 6 |
| 158 | + Cruise at an instance |
| 159 | + |
| 160 | + Explanation: |
| 161 | + Hour 1: |
| 162 | + Entry: 3 Exit: 0 |
| 163 | + No. of guests on ship: 3 |
| 164 | + |
| 165 | + Hour 2: |
| 166 | + Entry : 5 Exit : 2 |
| 167 | + No. of guest on ship: 3+5-2=6 |
| 168 | + |
| 169 | + Hour 3: |
| 170 | + Entry : 2 Exit: 4 |
| 171 | + No. of guests on ship: 6+2-4= 4 |
| 172 | + |
| 173 | + Hour 4: |
| 174 | + Entry: 0 Exit : 4 |
| 175 | + No. of guests on ship : 4+0-4=0 |
| 176 | + |
| 177 | + Hence, the maximum number of guests within 5 hours is 6. |
| 178 | + The input format for testing |
| 179 | + The candidate has to write the code to accept 3 input. |
| 180 | + First input- Accept value for number of T(Positive integer number) |
| 181 | + Second input- Accept T number of values, where each value is separated by a new line. |
| 182 | + Third input- Accept T number of values, where each value is separated by a new line. |
| 183 | + The output format for testing |
| 184 | + The output should be a positive integer number or a message as given in the problem statement(Check the output in Example 1 and Example 2) |
| 185 | + |
| 186 | + Constraints: |
| 187 | + |
| 188 | + 1<=T<=25 |
| 189 | + 0<= E[i] <=500 |
| 190 | + 0<= L[i] <=500 |
| 191 | + |
| 192 | +6. |
| 193 | + At a fun fair, a street vendor is selling different colours of balloons. He sells N number of different colours of balloons (B[]). The task is to find the colour (odd) of the balloon which is present odd number of times in the bunch of balloons. |
| 194 | + |
| 195 | + Note: If there is more than one colour which is odd in number, then the first colour in the array which is present odd number of times is displayed. The colours of the balloons can all be either upper case or lower case in the array. If all the inputs are even in number, display the message “All are even”. |
| 196 | + |
| 197 | + Example 1: |
| 198 | + |
| 199 | + 7 -> Value of N |
| 200 | + [r,g,b,b,g,y,y] -> B[] Elements B[0] to B[N-1], where each input element is sepārated by ṉew line. |
| 201 | + Output : |
| 202 | + |
| 203 | + r -> [r,g,b,b,g,y,y] -> “r” colour balloon is present odd number of times in the bunch. |
| 204 | + Explanation: |
| 205 | + From the input array above: |
| 206 | + |
| 207 | + r: 1 balloon |
| 208 | + g: 2 balloons |
| 209 | + b: 2 balloons |
| 210 | + y : 2 balloons |
| 211 | + Hence , r is only the balloon which is odd in number. |
| 212 | + Example 2: |
| 213 | + Input: |
| 214 | + |
| 215 | + 10 -> Value of N |
| 216 | + [a,b,b,b,c,c,c,a,f,c] -> B[], elements B[0] to B[N-1] where input each element is separated by new line. |
| 217 | + Output : |
| 218 | + b-> ‘b’ colour balloon is present odd number of times in the bunch. |
| 219 | + |
| 220 | + Explanation: |
| 221 | + From the input array above: |
| 222 | + |
| 223 | + a: 2 balloons |
| 224 | + b: 3 balloons |
| 225 | + c: 4 balloons |
| 226 | + f: 1 balloons |
| 227 | + Here, both ‘b’ and ‘f’ have odd number of balloons. But ‘b’ colour balloon occurs first. |
| 228 | + Hence , b is the output. |
| 229 | + |
| 230 | + Input Format for testing |
| 231 | + The candidate has to write the code to accept: 2 input |
| 232 | + |
| 233 | + First input: Accept value for number of N(Positive integer number). |
| 234 | + Second Input : Accept N number of character values (B[]), where each value is separated by a new line. |
| 235 | + Output format for testing |
| 236 | + The output should be a single literal (Check the output in example 1 and example 2) |
| 237 | + |
| 238 | + Constraints: |
| 239 | + |
| 240 | + 3<=N<=50 |
| 241 | + B[i]={{a-z} or {A-Z}} |
| 242 | + |
| 243 | +7. |
| 244 | + There is a JAR full of candies for sale at a mall counter. JAR has the capacity N, that is JAR can contain maximum N candies when JAR is full. At any point of time. JAR can have M number of Candies where M<=N. Candies are served to the customers. JAR is never remain empty as when last k candies are left. JAR if refilled with new candies in such a way that JAR get full. |
| 245 | + Write a code to implement above scenario. Display JAR at counter with available number of candies. Input should be the number of candies one customer can order at point of time. Update the JAR after each purchase and display JAR at Counter. |
| 246 | + |
| 247 | + Output should give number of Candies sold and updated number of Candies in JAR. |
| 248 | + |
| 249 | + If Input is more than candies in JAR, return: “INVALID INPUT” |
| 250 | + Given, |
| 251 | + N=10, where N is NUMBER OF CANDIES AVAILABLE |
| 252 | + K =< 5, where k is number of minimum candies that must be inside JAR ever. |
| 253 | + Example 1:(N = 10, k =< 5) |
| 254 | + |
| 255 | + Input Value |
| 256 | + 3 |
| 257 | + Output Value |
| 258 | + NUMBER OF CANDIES SOLD : 3 |
| 259 | + NUMBER OF CANDIES AVAILABLE : 7 |
| 260 | + |
| 261 | + Example : (N=10, k<=5) |
| 262 | + |
| 263 | + Input Value |
| 264 | + 0 |
| 265 | + Output Value |
| 266 | + INVALID INPUT NUMBER OF |
| 267 | + CANDIES LEFT : 10 |
| 268 | + |
| 269 | +8. |
| 270 | + Selection of MPCS exams include a fitness test which is conducted on ground. There will be a batch of 3 trainees, appearing for running test in track for 3 rounds. You need to record their oxygen level after every round. After trainee are finished with all rounds, calculate for each trainee his average oxygen level over the 3 rounds and select one with highest oxygen level as the most fit trainee. If more than one trainee attains the same highest average level, they all need to be selected. |
| 271 | + |
| 272 | + Display the most fit trainee (or trainees) and the highest average oxygen level. |
| 273 | + |
| 274 | + Note: |
| 275 | + |
| 276 | + The oxygen value entered should not be accepted if it is not in the range between 1 and 100. |
| 277 | + If the calculated maximum average oxygen value of trainees is below 70 then declare the trainees as unfit with meaningful message as “All trainees are unfit. |
| 278 | + Average Oxygen Values should be rounded. |
| 279 | + Example 1: |
| 280 | + INPUT VALUES |
| 281 | + 95 |
| 282 | + 92 |
| 283 | + 95 |
| 284 | + 92 |
| 285 | + 90 |
| 286 | + 92 |
| 287 | + 90 |
| 288 | + 92 |
| 289 | + 90 |
| 290 | + |
| 291 | + OUTPUT VALUES |
| 292 | + Trainee Number : 1 |
| 293 | + Trainee Number : 3 |
| 294 | + |
| 295 | + Note: |
| 296 | + Input should be 9 integer values representing oxygen levels entered in order as |
| 297 | + |
| 298 | + Round 1 |
| 299 | + |
| 300 | + Oxygen value of trainee 1 |
| 301 | + Oxygen value of trainee 2 |
| 302 | + Oxygen value of trainee 3 |
| 303 | + Round 2 |
| 304 | + |
| 305 | + Oxygen value of trainee 1 |
| 306 | + Oxygen value of trainee 2 |
| 307 | + Oxygen value of trainee 3 |
| 308 | + Round 3 |
| 309 | + |
| 310 | + Oxygen value of trainee 1 |
| 311 | + Oxygen value of trainee 2 |
| 312 | + Oxygen value of trainee 3 |
| 313 | + Output must be in given format as in above example. For any wrong input final output should display “INVALID INPUT” |
| 314 | + |
| 315 | +9. |
| 316 | + Problem Statement |
| 317 | + |
| 318 | + A washing machine works on the principle of Fuzzy System, the weight of clothes put inside it for washing is uncertain But based on weight measured by sensors, it decides time and water level which can be changed by menus given on the machine control area. |
| 319 | + |
| 320 | + For low level water, the time estimate is 25 minutes, where approximately weight is between 2000 grams or any nonzero positive number below that. |
| 321 | + |
| 322 | + For medium level water, the time estimate is 35 minutes, where approximately weight is between 2001 grams and 4000 grams. |
| 323 | + |
| 324 | + For high level water, the time estimate is 45 minutes, where approximately weight is above 4000 grams. |
| 325 | + |
| 326 | + Assume the capacity of machine is maximum 7000 grams |
| 327 | + |
| 328 | + Where approximately weight is zero, time estimate is 0 minutes. |
| 329 | + |
| 330 | + Write a function which takes a numeric weight in the range [0,7000] as input and produces estimated time as output is: “OVERLOADED”, and for all other inputs, the output statement is |
| 331 | + |
| 332 | + “INVALID INPUT”. |
| 333 | + |
| 334 | + Input should be in the form of integer value – |
| 335 | + |
| 336 | + Output must have the following format – |
| 337 | + |
| 338 | + Time Estimated: Minutes |
| 339 | + |
| 340 | + Example: |
| 341 | + Input value |
| 342 | + 2000 |
| 343 | + Output value |
| 344 | + Time Estimated: 25 minutes |
| 345 | + |
| 346 | +10. |
| 347 | + Problem Statement |
| 348 | + |
| 349 | + The Caesar cipher is a type of substitution cipher in which each alphabet in the plaintext or messages is shifted by a number of places down the alphabet. |
| 350 | + For example,with a shift of 1, P would be replaced by Q, Q would become R, and so on. |
| 351 | + To pass an encrypted message from one person to another, it is first necessary that both parties have the ‘Key’ for the cipher, so that the sender may encrypt and the receiver may decrypt it. |
| 352 | + Key is the number of OFFSET to shift the cipher alphabet. Key can have basic shifts from 1 to 25 positions as there are 26 total alphabets. |
| 353 | + As we are designing custom Caesar Cipher, in addition to alphabets, we are considering numeric digits from 0 to 9. Digits can also be shifted by key places. |
| 354 | + For Example, if a given plain text contains any digit with values 5 and keyy =2, then 5 will be replaced by 7, “-”(minus sign) will remain as it is. Key value less than 0 should result into “INVALID INPUT” |
| 355 | + |
| 356 | + Example 1: |
| 357 | + Enter your PlainText: All the best |
| 358 | + Enter the Key: 1 |
| 359 | + |
| 360 | + The encrypted Text is: Bmm uif Cftu |
| 361 | + |
| 362 | + Write a function CustomCaesarCipher(int key, String message) which will accept plaintext and key as input parameters and returns its cipher text as output. |
0 commit comments