+ 2

Can anyone tell me why it is not passing the test cases?

import java. util.*; public class Program { public static void main(String[] args) { Scanner sc=new Scanner (System.in); ArrayList <String> n=new ArrayList <>(); String t=sc.next(); int a=sc.nextInt(); for(int i=0;i<4;i++) { n.add(sc.next()); } n.add(t); Collections.sort(n); //System.out.print(n); for(int i=0;i<n.size();i++) { if(t==n.get(i)) { System.out.println (20*(i+1)); break ; } } } }

11th Jun 2021, 7:32 PM
Atul [Inactive]
29 Answers
+ 2
How Zeb will require 20 mins ? Can you elaborate the times of bem Bob Jan pan also? Please
11th Jun 2021, 8:23 PM
Atul [Inactive]
+ 2
Jayakrishna🇮🇳 Oh sorry for asking codes ,is posting code coach solutions in the code playground is against the rules?
12th Jun 2021, 7:23 PM
Atul [Inactive]
+ 2
Jayakrishna🇮🇳 Is asking doubts of it is also prohibited. I asked for 2 code coach only because I was unable to understand the question I never ask for codes
12th Jun 2021, 7:49 PM
Atul [Inactive]
+ 2
Check out this 👇 import java.util.Scanner; import java.util.Arrays; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); String customer = input.next(); int agents = input.nextInt(); input.nextLine(); String otherCustomers = input.nextLine(); String allCustomers = otherCustomers + " " + customer; String [] waitingList = allCustomers.split("\\s"); Arrays.sort(waitingList); int place = 0; for (int i=0; i<waitingList.length; i++) { if (waitingList[i].equals(customer)){ place = i; } } int time = (int)((place/agents+1)*20); System.out.print(time); } }
13th Jun 2021, 4:52 PM
Tharul Nejana
Tharul Nejana - avatar
+ 1
Jayakrishna🇮🇳 Can you please explain the number of agents stuff if you look at the first test case?
11th Jun 2021, 7:52 PM
Atul [Inactive]
+ 1
If here the work is done with the indexing then why not in other cases?
11th Jun 2021, 8:11 PM
Atul [Inactive]
+ 1
Did you observed that you are not using agent 'a' value anywhere.. it's the actual parameter in the problem. See for example same sample with a=5, Zeb 5 Bob Jan Ben Pat Here, agent =5, each one can interview a person in 20mins .. in order " Ben Bob Jan Pan Zeb " So Zeb is the 5th person, can get slot 1st time by 5th agent so 1*20=20mins needed for his interview completion... Is that clears ?
11th Jun 2021, 8:17 PM
Jayakrishna 🇮🇳
+ 1
Anyone please help I am unable to get answer?
12th Jun 2021, 7:33 AM
Atul [Inactive]
+ 1
Jayakrishna🇮🇳 you mean like this? System.out.println (20*(i+1)/a);
12th Jun 2021, 12:38 PM
Atul [Inactive]
+ 1
Jayakrishna🇮🇳 Not completed 2 cases
12th Jun 2021, 12:51 PM
Atul [Inactive]
+ 1
Jayakrishna🇮🇳 Please don't provide me any code. I want to completely do it by myself
12th Jun 2021, 12:51 PM
Atul [Inactive]
+ 1
Jayakrishna🇮🇳 in case if you can provide any other examples because the visible test cases and the example given by you works out here
12th Jun 2021, 1:42 PM
Atul [Inactive]
+ 1
Getting answer using this System.out.println (20*((i/a)+1));
12th Jun 2021, 2:09 PM
Atul [Inactive]
+ 1
Jayakrishna🇮🇳 thanks for your help. Can post your Sol?
12th Jun 2021, 5:48 PM
Atul [Inactive]
+ 1
20*(I+agents) don't fullfill the cases
12th Jun 2021, 6:54 PM
Atul [Inactive]
+ 1
Thanks for the information Jayakrishna🇮🇳
13th Jun 2021, 10:59 AM
Atul [Inactive]
0
i think you are counting only when Agents a = 1, but not for more agents... For ex: Z 4 A B C D The output should be 40 I think. Because 4agents will test 4people in 20 mins so Person Z comes next and he comes out after 20mins so total 20+20=40mins only but code output is 100 Read again description.. hope it helps ..
11th Jun 2021, 7:48 PM
Jayakrishna 🇮🇳
0
Zeb 1 Bob Jan Ben Pat Here, agent =1 he can interview a person 20mins .. in order " Ben Bob Jan Pan Zeb " So Zeb is the 5th person, can get slot 5th time so 5*20=100mins needed for his interview completion.
11th Jun 2021, 8:03 PM
Jayakrishna 🇮🇳
0
The 1st input is the person for whom we need to calculate his completion time of interview. One agent can can interview a person in 20mins. Interview is conducted in alphabetical order. Then so total 5person came to interview. No.of Agents is input. So first arrange all in alphabetical order and find input person completion time. Zeb 5 Bob Jan Ben Pat Here, agent =5, we need to find Zeb completion time. Each one agent can interview a person in 20mins .. in order " Ben Bob Jan Pan Zeb " 1st agent interview Ben 2nd interviews Bob 3rd interviews Jan 4th interviews Pan 5th interviews Zeb All will be interviewed at the same time,and each takes 20mins. So Zeb is the 5th person, can get slot 1st time by 5th agent so 20mins needed for his interview completion... Note: there are 5 interview halls, 5 members will came for interview. If any agent can absent,then other remaining will take responsibility... (It does not mean , interviewed one after the other,they can conduct interview at simultaneously also...) ...?
12th Jun 2021, 11:53 AM
Jayakrishna 🇮🇳
0
Is that working in code coach .? .try it yourself. Are you understood the problem ? Or Do you want code solution? Its better to find yourself.
12th Jun 2021, 12:47 PM
Jayakrishna 🇮🇳