![]() The HashSet's Add method returns true if a value could be added so we can use it with a while loop until we find the next not yet drawn number. The trick is to use a HashSet for tracking drawn numbers that has a lookup of O(n) and to stop drawing new numbers if all 75 numbers has already been drawn because calls to the Next(.) method are expensive and the execution time unnecessarily increases. Pass via the constructor for testing purposes. Use System.Random to generate your random numbers. These are the ranges that you must follow:Ī number within range 1 to 15 starts with a 'B'Ī number within range 16 to 30 starts with an 'I'Ī number within range 31 to 45 starts with an 'N'Ī number within range 46 to 60 starts with a 'G'Ī number within range 61 to 75 starts with an 'O' The numbers are returned one by one in Bingo style: If there are no numbers left, return an empty string ![]() Return all numbers in the range of 1 until 75 once and in random order I need help optimizing my code so it can run faster. I am dong a competitive programming problem I have passed all the tests.īut my program times out. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |