0
The output does not show as expected. How to solve it?
Supposingly the array take user input for characters, no of query, and the queries. Example data are: Size of an array: 10 Characters: S Y R E N E A D Y R No of query: 5 Queries (take user input to search content in the array): RY E N S AY Expected output should be like this: 2 2 1 1 0 Any comment or advices will be apprieciate, and thanks in advance. https://code.sololearn.com/cgLc4yl3EmaW/?ref=app
10 Answers
+ 1
OK. This fit for that but need some changes, am trying but but not matching when RY length is greater than S. So need a special case. It will take time for me.
Hoping you can try it.. With this.
for(int y=0; y<newArr.size(); y++){
System.out.println(search+" "+newArr.get(y).substring(0,search.length()-1)+newArr.get(y)); if(search.equals(newArr.get(y).substring(0,search.length()-1))){
System.out.println(search+" "+newArr.get(y));
count++;
}
Edit:
Intan Zulaikha Faz check this one...
https://code.sololearn.com/caVUMA4EYoHL/?ref=app
+ 8
Intan Zulaikha Faz
The names of queens which you are forming will start becoming wrong if 2 or more queens will be having same number of mother.
Also, you only need to check with prefix(intial continuous character(s) of name) of a queen's name, not the whole name of a queen.
problem link : https://judge.icpc.global/problems/firstofhername
0
If in is
3
S
D
A
Then you are changing newarr like
S
DS
ADS
So if you input same like above it gives 1,2,3
Otherwise any other 0
And you printing count after all counting, not when match found so, output is only no.times the found match. And 5times..
0
Jayakrishna
At first, i try to find the target using boolean but still does not return the expected value
0
Intan Zulaikha Faz
I mentioned how your program executing..
So look again, and mention where your not able to get desired code...
In question, you didn't not spedified how you making new array.. And how you expecting expected array logic... May be not clear to me... So question need some more clarification for me...
0
Jayakrishna
At first part, i created an arraylist to take characters from the user input. Then, i created a new arraylist again to concat the characters into a string.
Second part, the program will get the size of query from the user and the user can input any character or string that they want to search from the second array which contains the string.
Third part, the program will find/search it and count the total of queries available.
Last part, the program will print the total queries that matches the user input.
I think you will be more understand my problem above if you check the ICPC problems for 2019, problem G titled "First of her name" from the icpc website
0
thanks, i will try it
Edit:
The code seems working just fine! Thank you very much Jayakrishna
0
Gaurav Agrawal okay, will try to fix my coding. Thanks
0
Intan Zulaikha Faz Is that incomplete yet?
I updated, tested. It giving the output...
Still any errors?
0
Jayakrishna it totally works! No error at all 👍