You are viewing a single comment's thread. Return to all comments →
I was facing an issue with the C# given code for this problem and finally solved it.
There's some issue with this code:
string arr_temp = Console.ReadLine().Split(' ');
int arr = Array.ConvertAll(arr_temp,Int32.Parse);
I'm not sure what it is. Maybe the platform this runs on is misinterpreting the size of arr_temp and it's not doing the converstion properly.
I had to instead individually parse using Int32.Parse for each element in arr_temp and put it into a new array arr.
I also used the hashmap way to solve this. It's a lot faster than the binary search option and passed all cases.
I added a Trim() after the ReadLine() and that fixed the runtime error.
string arr_temp = Console.ReadLine().Trim().Split(' ');
That was fun to find -_-
You saved my butt, I was passing all my test cases but getting an error on the submission cases. They really need to make sure that at least one or two of the submission cases are actually runable in the editor, all of these where too big.
Wow, here I am trying to solve this problem for the first time, not sure if my solution even makes sense, and it turns out there was an error reading the input T_T.
Anyways thanks for the fix dude!
How do you do a hashman in C#? Do you mean a dictionary?