7 531
Подписчики
-324 часа
-347 дней
-15030 день
Архив постов
Those who need help for Hexaware and any other placements.then contact us for clearance.
Any exam 100% clearance.
Contact : @mlcoder2
Accolite cleared . And got interview mail
100% clearance for any exam ✅✅✅
Tomorrow Accolite solutions group :
https://t.me/cod_solutions
TCS NEW JOINERS GROUP 👇👇👇
IPA DISCUSSION GROUP ON 20TH JANUARY
https://t.me/Cpa_ira_pra
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String inputCommands = br.readLine();
String inputData = br.readLine();
String[] commandTokens = inputCommands.split(",");
for (int i = 0; i < commandTokens.length; i++) {
commandTokens[i] = commandTokens[i].trim();
}
int numOutlets = 0;
int[][] productInfo = null;
String[] dataTokens = inputData.split(",");
for (int i = 0; i < dataTokens.length; i++) {
dataTokens[i] = dataTokens[i].trim();
if (i == 0) {
numOutlets = Integer.parseInt(dataTokens[i]);
} else {
if (productInfo == null) {
productInfo = new int[dataTokens.length - 1][3];
}
String[] product = dataTokens[i].substring(1, dataTokens[i].length() - 1).split(",");
productInfo[i - 1][0] = Integer.parseInt(product[0]);
productInfo[i - 1][1] = Integer.parseInt(product[1]);
productInfo[i - 1][2] = Integer.parseInt(product[2]);
}
}
maxDiscountSystem maxDiscountSystem = new maxDiscountSystem(numOutlets, productInfo);
List<List<Integer>> outputs = new ArrayList<>();
List<List<Product>> reportOutputs = new ArrayList<>();
for (String command : commandTokens) {
switch (command) {
case "search":
int product = Integer.parseInt(dataTokens[1]);
List<Integer> outlets = maxDiscountSystem.search(product);
outputs.add(outlets);
break;
case "report":
List<Product> products = maxDiscountSystem.report();
reportOutputs.add(products);
break;
default:
System.out.println("Invalid command");
}
}
}
}
class maxDiscountSystem {
int numOutlets;
List<Product> products;
public maxDiscountSystem(int numOutlets, int[][] productInfo) {
this.numOutlets = numOutlets;
this.products = new ArrayList<>();
for (int[] info : productInfo) {
int outlet = info[0];
int product = info[1];
int price = info[2];
this.products.add(new Product(outlet, product, price));
}
Collections.sort(this.products);
}
public List<Integer> search(int product) {
List<Integer> outlets = new ArrayList<>();
for (Product p : this.products) {
if (p.product == product) {
outlets.add(p.outlet);
}
}
return outlets;
}
public List<Product> report() {
List<Product> res = new ArrayList<>();
for (Product p : this.products) {
res.add(p);
if (res.size() == 5) {
break;
}
}
return res;
}
}
class Product implements Comparable<Product> {
int outlet;
int product;
int price;
public Product(int outlet, int product, int price) {
this.outlet = outlet;
this.product = product;
this.price = price;
}
@Override
public int compareTo(Product other) {
if (this.price != other.price) {
return this.price - other.price;
}
if (this.outlet != other.outlet) {
return this.outlet - other.outlet;
}
return this.product - other.product;
}
}
TCS HACKQUEST SOLUTIONS GROUP :
https://t.me/cod_solutions
Hello Guys! ✔️❤️
Those who have DELOITTE, HCL, Weily edge, TCS PAID NQT 📌nd any placement exams🎯 ON nd off campus
contact us nd book ur slots 🔥
Share to ur frds👬👫✔️❤️
@mlcoder2 - any placement Exam
Don’t miss the opportunity ❤️
110% percent selected🔥
And Anyone want help in interiew contact us📌
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
Share this group screenshot to your friends and college groups
I will send Technical answers and free coding Answers
