+ 1
Why its getting timed out???
function main() { let products = new Set([ "dumbbells", "barbell", "t-shirt", "swim short", "gloves", "training apparatus", "goggle" ]); var count = 0; while(count<3){ var itemType = readLine(); products.add(); //add the item to the set } //calculate and output the count of item types console.log(products.size); } Output : Execution is timed out!
4 Antworten
+ 1
You are not updating count value.
So count<3 is always true..
then it's an infinite while loop... Update count by
' count++; ' after reading input.
and
Evgeny Sergeev
also you need to add input to set by
products.add(itemType) ;
edit:
pls edit tag java to javascript.....
+ 1
You forgot to increment variable <count> in the while...loop. Due to that the loop goes infinitely.
+ 1
You are not incrementing the counter inside the while loop
0
Thanks everyone it worked !
I though count <3 cant go infinite beacuse stops on 2, is it correct?