CODING QUESTION 4 A college has opened registrations for a course. Due to the pandemic, the college has given both online and offline modes of registrations to that course. As an administrator, you are given the task to find the students who have applied for both online and offline modes and rectify it. (This answer is from a source of mine. Feel free to post your answers in as well.) CODE: import java.util.Scanner; import java.util.concurrent.ThreadLocalRandom; //function which prints all the duplicate id's public class Duplicates1 { public void findDuplicates(int[] id) { System.out.println("Duplicate student id : "); for (int i = 0; i < id.length; i++) { for (int j = i+1; j < id.length; j++) { if (id[i] == id[j]) { System.out.p...
Posts
- Get link
- X
- Other Apps
IMPORTANT FOR APTITUDE SQUARES: 1 2 = 1 2 2 = 4 3 2 = 9 4 2 = 16 5 2 = 25 6 2 = 36 7 2 = 49 8 2 = 64 9 2 = 81 10 2 = 100 11 2 = 121 12 2 = 144 13 2 = 169 14 2 = 196 15 2 = 225 16 2 = 256 17 2 = 289 18 2 = 324 19 2 = 361 20 2 = 400 21 2 = 441 22 2 = 484 23 2 = 529 24 2 = 576 25 2 = 625 TRICK: Add consecutive odd numbers to get the squares Ex: 1. 1 2 = 1 2. 1+3=4 3. 4= 2 2 CUBES: 1 3 = 1 2 3 = 8 3 3 = 27 4 3 = 64 5 3 = 125 6 3 = 216 7 3 = 343 8 3 = 512 9 3 = 729 10 3 = 1000 11 3 = 1331 12 3 = 1728 13 3 = 2197 14 3 = 2744 15 3 = 3375 16 3 = 4096 17 3 = 4913 18 3 = 5832 19 3 = 6859 20 3 = 8000 21 3 =...
- Get link
- X
- Other Apps
CODING QUESTION 3 Odd Sum (CODECHEF OCTOBER COOK-OFF CHALLENGE 2021) Given an integer N , consider all arrays A of size N such that: All the elements are non-negative and distinct. All prefix sums are odd. Formally, for all i i such that 1 ≤ i ≤ N , ∑ i j = 1 A i is odd. Among all possible arrays A , output the smallest possible sum of the elements of the array. Note : Since the Input/Output may be large, it is preferred to use fast I/O. Input Format The first line contains T - the number of test cases. Then the test cases follow. The first line of each test case contains N - the size of the array. Output Format For each test case, output on one line the smallest sum among all arrays satisfying the constraints. Constraints 1 ≤ T ≤ 10 6 1 ≤ N ≤ 10 9 Sample Input 1 1 3 Sample Output 1 3 Explanation Test case 1 : A possible array is [ 1 , 2 , 0 ] . [ 1 ...