├── Keys ├── key_op1.png └── Keys.java ├── Bingo ├── bingo_op1.png └── Bingo.java ├── Pipes ├── pipes_op1.png ├── pipes_op2.png └── Pipes.java ├── ToysFun ├── toys_op.png └── ToysFun.java ├── YoursPay ├── pay_op.png └── YoursPay.java ├── BeautifyMe ├── bMe_op1.jpg ├── bMe_op2.jpg └── BeautifyMe.java ├── BucketId ├── bucket_op1.png ├── bucket_op2.png └── BucketID.java ├── FunGames ├── funG_op1.png ├── funG_op2.png └── FunGames.java ├── OilFactory ├── oil_op1.png ├── oil_op2.png └── OilFactory.java ├── Save_Earth ├── save_op1.png ├── save_op2.png └── SaveEarth.java ├── BuySell-Goods ├── goods_op1.png ├── goods_op2.png └── BuySellGoods.java ├── ClimateToday ├── climate_op1.png └── ClimateToday.java ├── Feel-Good ├── feelGood_op1.png ├── feelGood_op2.png └── FeelGood.java ├── Maths-Tutorial ├── math_op1.png └── MathsTutorial.java ├── Number_of_plots ├── plot_op1.png ├── plot_op2.png └── ApparelPlots.java ├── ThePastBook ├── PastBook_op1.png ├── PastBook_op2.png └── PastBook.java ├── Unique-Authors ├── unique_aut1.png └── UniqueAuthors.java ├── LICENSE └── README.md /Keys/key_op1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/Keys/key_op1.png -------------------------------------------------------------------------------- /Bingo/bingo_op1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/Bingo/bingo_op1.png -------------------------------------------------------------------------------- /Pipes/pipes_op1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/Pipes/pipes_op1.png -------------------------------------------------------------------------------- /Pipes/pipes_op2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/Pipes/pipes_op2.png -------------------------------------------------------------------------------- /ToysFun/toys_op.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/ToysFun/toys_op.png -------------------------------------------------------------------------------- /YoursPay/pay_op.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/YoursPay/pay_op.png -------------------------------------------------------------------------------- /BeautifyMe/bMe_op1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/BeautifyMe/bMe_op1.jpg -------------------------------------------------------------------------------- /BeautifyMe/bMe_op2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/BeautifyMe/bMe_op2.jpg -------------------------------------------------------------------------------- /BucketId/bucket_op1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/BucketId/bucket_op1.png -------------------------------------------------------------------------------- /BucketId/bucket_op2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/BucketId/bucket_op2.png -------------------------------------------------------------------------------- /FunGames/funG_op1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/FunGames/funG_op1.png -------------------------------------------------------------------------------- /FunGames/funG_op2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/FunGames/funG_op2.png -------------------------------------------------------------------------------- /OilFactory/oil_op1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/OilFactory/oil_op1.png -------------------------------------------------------------------------------- /OilFactory/oil_op2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/OilFactory/oil_op2.png -------------------------------------------------------------------------------- /Save_Earth/save_op1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/Save_Earth/save_op1.png -------------------------------------------------------------------------------- /Save_Earth/save_op2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/Save_Earth/save_op2.png -------------------------------------------------------------------------------- /BuySell-Goods/goods_op1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/BuySell-Goods/goods_op1.png -------------------------------------------------------------------------------- /BuySell-Goods/goods_op2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/BuySell-Goods/goods_op2.png -------------------------------------------------------------------------------- /ClimateToday/climate_op1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/ClimateToday/climate_op1.png -------------------------------------------------------------------------------- /Feel-Good/feelGood_op1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/Feel-Good/feelGood_op1.png -------------------------------------------------------------------------------- /Feel-Good/feelGood_op2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/Feel-Good/feelGood_op2.png -------------------------------------------------------------------------------- /Maths-Tutorial/math_op1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/Maths-Tutorial/math_op1.png -------------------------------------------------------------------------------- /Number_of_plots/plot_op1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/Number_of_plots/plot_op1.png -------------------------------------------------------------------------------- /Number_of_plots/plot_op2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/Number_of_plots/plot_op2.png -------------------------------------------------------------------------------- /ThePastBook/PastBook_op1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/ThePastBook/PastBook_op1.png -------------------------------------------------------------------------------- /ThePastBook/PastBook_op2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/ThePastBook/PastBook_op2.png -------------------------------------------------------------------------------- /Unique-Authors/unique_aut1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutuja1302/WIPRO-NLTH/HEAD/Unique-Authors/unique_aut1.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Rutuja Mhatre 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /BeautifyMe/BeautifyMe.java: -------------------------------------------------------------------------------- 1 | /*Program Statement: 2 | * The cosmetic company "BeautifyMe" wishes to know the alphabetic product code from the barcode. The barcode of the product is a numeric value and the alphabetic product is a string value tagged 'a-j'. 3 | * The alphabetic range 'a-j' represents the numeric range '0-9'. To produce the alphabetic product code, each digit in the numeric barcode is replaced by the corresponding matching letters. 4 | * Write an algorithm to display the alphabetic product code from the numeric barcode. 5 | * 6 | * Input 7 | * The input consists of an integer - barcode, that represents the barcode of the product. 8 | * 9 | * Output 10 | * Print a string representing the alphabetic product code. 11 | * 12 | * Constraints 13 | * 0 <= barcode <= 10^10 14 | * 15 | * Example 16 | * Input 17 | * 12403 18 | * 19 | * Output 20 | * bcead 21 | * 22 | * Explanation 23 | * The corresponding letters for the numeric barcode 12403 is 'bcead'*/ 24 | 25 | import java.util.Scanner; 26 | public class BeautifyMe { 27 | public static void main(String[] args) { 28 | Scanner scan = new Scanner(System.in); 29 | Long barcode = scan.nextLong(); //read input barcode from user 30 | char[] alphabets = {'a','b','c','d','e','f','g','h','i','j'}; //aplhabets representing numbers from 0-9 31 | String result = ""; //string to store result 32 | while(barcode>0) { 33 | int rem = (int) (barcode%10); //returns last digit 34 | result = alphabets[rem] + result; //returns the string with alphabet representing int rem & previous result 35 | barcode = barcode/10; //returns the remaining digits 36 | } 37 | System.out.println(result); //displaying result 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Maths-Tutorial/MathsTutorial.java: -------------------------------------------------------------------------------- 1 | /*Program Statement - 2 | * In an online maths tutorial a student is given a list of N numbers. 3 | * From this list, the student is required to sum each element in the list such that the ith element in the output list will be equal to the sum to the first element until the ith element in the list. 4 | * 5 | * Write an algorithm to calculate the sum of each element in the list. 6 | * 7 | * Input 8 | * The first line of input consists of an integer - numSize, representing the count of total numbers in the list (N). 9 | * The next line consists of N - separated integers - 10 | * element1, element2,.....elementN-1 representing the numeric value in the list. 11 | * 12 | * Output 13 | * Print N space-separated integers representing the sum of each element in the list. 14 | * 15 | * Constraints 16 | * 0 <= numSize <= 10^6 17 | * -10^6 <= elementi <= 10^6 18 | * 0 <= i < numSize 19 | * 20 | * Example 21 | * Input 22 | * 5 23 | * 1 4 2 6 3 24 | * 25 | * Output 26 | * 1 5 7 13 16*/ 27 | 28 | import java.util.Scanner; 29 | public class MathsTutorial { 30 | public static void main(String[] args) { 31 | Scanner scan = new Scanner(System.in); 32 | int numSize = scan.nextInt(); //resd input N 33 | int[] element = new int[numSize]; //initialize an array of N elements 34 | //read N elemens from input 35 | for(int i=0; imax) { 50 | System.out.print(temp[i]+" "); 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /FunGames/FunGames.java: -------------------------------------------------------------------------------- 1 | /*The games development company "FunGames" has developed a balloon shooter game. The balloons are arranged in a linear sequence and each balloon has a number associated with it. 2 | * The numbers on the balloons are in fibonacci series. In the game the player shots 'k' balloons. The player's score is the sum of the numbers on the 'k' balloons. 3 | * 4 | * Write an algorithm to generate the player's score. 5 | * 6 | * Input 7 | * The input consists of an integer - numBalloons representing the total number of balloons shot by the player(k). 8 | * Output 9 | * Print an integer value representing the player's score. If no balloons are shot then print 0. 10 | * 11 | * Constraints 12 | * 0 <= numBalloons <= 10^6 13 | * 14 | * Example 15 | * Input 16 | * 7 17 | * Output 18 | * 20 19 | * 20 | * Explanation 21 | * The fibonacci sum is 0+1+1+2+3+5+8=20*/ 22 | 23 | import java.util.Scanner; 24 | public class FunGames { 25 | //method to generate fibonacci series of n number of balloons and return the sum of the series 26 | public static int fibo(int n) { 27 | int[] fibs = new int[n]; //fibonacci series array 28 | //first two elements of fibonacci series initialization 29 | fibs[0] = 0; 30 | fibs[1] = 1; 31 | int sum=0; //initializing sum variable to store the sum of the series 32 | //nth element of fibo series = sum of its previous two elements 33 | for(int i=2;i0) { //loop will iterate until size of file is 0 48 | int temp = fileSize[i]%10; //returns the last digit 49 | id += temp; 50 | fileSize[i] /= 10; //divides to eliminate the last digit of the number 51 | } 52 | System.out.print(id+" "); //print the result 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /YoursPay/YoursPay.java: -------------------------------------------------------------------------------- 1 | /*The new bank, "YoursPay" has a list of N customers' bank account balances. 2 | * The list consists of both positive and negative balances. The positive balance signifies the current year's customers and the negative balance signifies last year's customers. 3 | * The bank has decided to offer shortlisted customers credit scores to their credit cards. The credit score will be the sum of the two balances from the list with the smallest product when multiplied. 4 | * If the credit score is positive then the credit will be provided to the current year's customer, otherwise it will go to the last year's customer. 5 | * 6 | * Write an algorithm to find the credit score.​ 7 | * 8 | * Input 9 | * The first line of input consists of an integer - numCustomers, representing the number of banking customers (N). 10 | * The second line of input consists of N space separated integers - balance0, balance1,...balanceN-1 representing the customers bank balances. 11 | * 12 | * Output 13 | * Print an integer representing the credit score. 14 | * 15 | * Constraints 16 | * 2 <= numCustomers <= 10^9 17 | * -10^9 <= balancei <= 10^9 18 | * 0 <= i < numCustomers 19 | * 20 | * Example 21 | * Input 22 | * 5 23 | * 1 8 -5 7 5 24 | * Output 25 | * 3 26 | * */ 27 | 28 | import java.util.Scanner; 29 | public class YoursPay { 30 | public static void main(String[] args) { 31 | Scanner scan = new Scanner(System.in); 32 | 33 | int numCustomers = scan.nextInt(); 34 | int[] balance = new int[numCustomers]; 35 | 36 | for(int i=0; i maxProduct) { 43 | maxProduct = cards[i] * cards[j]; 44 | card1 = cards[i]; 45 | card2 = cards[j]; 46 | } 47 | } 48 | } 49 | //sum of 2 highest product giving cards 50 | int sum = card1 + card2; 51 | System.out.println(sum); //display output 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /ToysFun/ToysFun.java: -------------------------------------------------------------------------------- 1 | /*The children's toy making company "ToysFun" is building cubic shaped learning toys. 2 | * The company has a list of N dimensions suggested by its designers for the toys that are perfect cube numbers. To do this, they need to know the total count of perfect cube numbers present in the list of dimensions. 3 | * 4 | * Write an algorithm to help the toy manufacturers find the total count of perfect cube numbers present in the list of dimensions. 5 | * 6 | * Input 7 | * The first line of input consists of an integer - numDimensions representing the total number of dimensions selected by the designers (N). 8 | * The second line of input consists of N space separated integers - dimens1, dimens2,....,dimensN-1 representing the value of the dimensions selected by the designers. 9 | * 10 | * Output 11 | * Print an integer value representing the total count of the dimensions that are perfect cube numbers. 12 | * 13 | * Constraints 14 | * 0 < numDimensions <= 10^6 15 | * 0 < dimens < 10^6 16 | * 0 <= i < numDimensions 17 | * 18 | * Example 19 | * Input 20 | * 9 21 | * 23 1 8 56 27 67 64 125 232 22 | * 23 | * Output 24 | * 5*/ 25 | 26 | import java.util.Scanner; 27 | public class ToysFun { 28 | //method to determine whether the dimension is a perfect cube or not. 29 | public static boolean dimens_is_cube(int n) { 30 | int i=1; 31 | boolean result = false; 32 | while(i<=n) { 33 | if(i*i*i == n) { 34 | result = true; 35 | break; 36 | } 37 | i++; 38 | } 39 | return result; 40 | } 41 | public static void main(String[] args) { 42 | Scanner scan = new Scanner(System.in); 43 | //read input 44 | int numDimensions = scan.nextInt(); 45 | int[] dimens = new int[numDimensions]; //initialize an array to store dimensions 46 | for(int i=0;i0) { 43 | unique++; 44 | } 45 | } 46 | System.out.println(unique); //print the output 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /BuySell-Goods/BuySellGoods.java: -------------------------------------------------------------------------------- 1 | /*The e-commerce company "BuySellGoods" collected the sales value of N most popular selling products on its website. 2 | * From these values the company decides to calculate the total sales value of the two highest selling products. 3 | * 4 | * Write an algorithm to help the company calculate the total sales value of the two highest selling products on its website. 5 | * 6 | * Input 7 | * The first line of input consists of an integer- numProducts representing the total number of products (N). 8 | * The next line consists of N space-separated integers- saleValue[1], salesValue[2]....... saleValue[N], 9 | * representing the sales value of the N selected products. 10 | * 11 | * Output 12 | * Print an integer representing the total sales value of the two highest selling products on the website. 13 | * 14 | * Constraints 15 | * 2 <= numProducts <= 10^6 16 | * 17 | * Note 18 | * More than one product can have a similar sales value. 19 | * 20 | * Example 21 | * Input 22 | * 5 23 | * 15 26 13 7 45 24 | * 25 | * Output 26 | * 71 27 | * 28 | * Explanation 29 | * The two products with highest sales value are the second the fifth products. Hence the total sales value is 71 (26+45) 30 | * */ 31 | 32 | import java.util.Scanner; 33 | public class BuySellGoods { 34 | public static void main(String[] args) { 35 | int res; //initialize variable to store result 36 | Scanner scan = new Scanner(System.in); 37 | //read n 38 | int numProducts = scan.nextInt(); 39 | //initialiaze array of n integers representing the sales values 40 | int[] saleValue = new int[numProducts]; 41 | //read the sales values from input 42 | for(int i=0;i 2. So, the remaining pipes are 3,2,6 and 5. 27 | * In the next turn, the drone picks the pipe with length 6 as 6 > 2. So, the remaining pipes are 3,2 and 5. 28 | * In the next turn, the drone picks the pipe with length 5 as 5 > 2. So, the remaining pipes are 3 and 2. 29 | * Now there are no more pipes left which can be carried to the carrier truck. So, the remaining pipes in the warehouse are 3 and 2.*/ 30 | 31 | import java.util.Scanner; 32 | public class Pipes { 33 | public static void main(String[] args) { 34 | Scanner scan = new Scanner(System.in); 35 | int numOfPipes = scan.nextInt(); 36 | //scan inputs 37 | int[] len = new int[numOfPipes]; 38 | for(int i=0; i= 1000 and <= 9999 3 | * i.e. 4 | * 1000 <= input1 <= 9999 5 | * 1000 <= input2 <= 9999 6 | * 1000 <= input3 <= 9999 7 | * You are expected to find the key using the below formula - 8 | * key = [SMALLEST digit in the thousands place of all three numbers][LARGEST digit in the hundreds place of all three numbers] 9 | * [SMALLEST digit in the tens place of all three numbers][LARGEST digit in the units place of all three numbers] 10 | * 11 | * Given three numbers, write an algorithm to find the key using the above mentioned formula. 12 | * 13 | * Input 14 | * The input consists of three space-separated integers - input1, input2 and input3 representing the three four - digit numbers. 15 | * 16 | * Output 17 | * Print an integer representing the concatenation of four digits where first digit represents the smallest digit in the thousands place of all three numbers; 18 | * second digit represents the largest digit in the hundreds place of all three numbers; third digit represents the smallest digit in the tens place of all three numbers and fourth digit represents the largest digit in the units place of all three numbers. 19 | * 20 | * Example 21 | * Input: 22 | * 3521 2452 1352 23 | * Output: 24 | * 1522*/ 25 | 26 | import java.util.Scanner; 27 | public class Key { 28 | public static void main(String[] args) { 29 | Scanner scan = new Scanner(System.in); 30 | //read 3 input numbers 31 | int input1 = scan.nextInt(); 32 | int input2 = scan.nextInt(); 33 | int input3 = scan.nextInt(); 34 | 35 | int result_key = 0; //variable to store result 36 | int temp1,temp2,temp3; //variables to store temp values 37 | int place = 1; //variable to store places: 1=units 10=tens and so on 38 | 39 | while(input1!=0 && input2!=0 && input3!=0) { 40 | //temp variables to store the last digit of the given inputs 41 | temp1 = input1%10; 42 | temp2 = input2%10; 43 | temp3 = input3%10; 44 | 45 | //unit place 46 | if(place==1) { 47 | result_key = Math.max(temp1, Math.max(temp2, temp3)); 48 | 49 | } 50 | //tens place 51 | if(place==10) { 52 | result_key = (Math.min(temp1, Math.min(temp2, temp3))*10) + result_key; 53 | 54 | } 55 | //hundreds place 56 | if(place==100) { 57 | result_key = (Math.max(temp1, Math.max(temp2, temp3))*100) + result_key; 58 | } 59 | //thousands place 60 | if(place==1000) { 61 | result_key = (Math.min(temp1, Math.min(temp2, temp3))*1000) + result_key; 62 | 63 | } 64 | 65 | //eliminate the last digit 66 | input1 /= 10; 67 | input2 /= 10; 68 | input3 /= 10; 69 | place *= 10; //upgrade the place counter 70 | } 71 | System.out.println(result_key); //display the output 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /OilFactory/OilFactory.java: -------------------------------------------------------------------------------- 1 | /*An oil factory has N number of containers and each has a different capacity. 2 | * During renovation, the manager decided to make some changes with the containers. He wishes to make different pairs for the containers in such a way that in the the first pair, the container of maximum capacity is paired with the container of minimum capacity, and so on for the rest of the containers, 3 | * to maintain balance throughout all the pairs of containers. 4 | * 5 | * Write an algorithm to make different pairs of containers in such a way that the first container in the pair is of maximum capacity and second container in the pair is of minimum capacity. 6 | * 7 | * Input 8 | * The first line of the input consists of an integer - numContainers, representing the number of containers (N). 9 | * The next line consists of N space-separated integers - cont1, cont2,....contN, representing container capacity. 10 | * 11 | * Output 12 | * Print K lines consisting of two space-separated integers representing the pairs that will be formed to maintain the balance by pairing the container of maximum capacity with the container of minimum capacity and so on. 13 | * 14 | * Constraints 15 | * 1 <= numContainers <= 10^3 16 | * 1 <= conti <= 10^3 17 | * 1 <= i <= numContainers 18 | * 19 | * Note 20 | * If only one container is left and no pair is possible then print the capacity of that container and the second value will be '0' 21 | * 22 | * Example 23 | * Example 1: 24 | * Input: 25 | * 6 26 | * 100 560 23 19 53 20 27 | * Output: 28 | * 560 19 29 | * 100 20 30 | * 53 23 31 | * Explanation: We have 6 containers with the capacity (100, 560, 23, 19, 53, 20), so we can form the following pairs of containers - (560,19),(100,20),(53,23) 32 | * 33 | * Example 2: 34 | * Input: 35 | * 7 36 | * 99 123 77 12 43 8 50 37 | * Output: 38 | * 123 8 39 | * 99 12 40 | * 77 43 41 | * 50 0*/ 42 | 43 | import java.util.Scanner; 44 | public class OilFactory { 45 | public static void main(String[] args) { 46 | Scanner scan = new Scanner(System.in); 47 | 48 | //read inputs 49 | int numContainers = scan.nextInt(); 50 | int[] cont = new int[numContainers]; 51 | for(int i=0;icont[j]) { 58 | int temp = cont[i]; 59 | cont[i] = cont[j]; 60 | cont[j] = temp; 61 | } 62 | } 63 | } 64 | int mid = numContainers/2; //variable to store middle element 65 | int n = numContainers-1; //to keep track of the last element 66 | 67 | for(int i=0; i