We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Strange Grid Again
Strange Grid Again
Sort by
recency
|
271 Discussions
|
Please Login in order to post a comment
just return this with long long types 10*((r-1)/2)+(r+1)%2+2*(c-1) the (r-1)/2 part will give integer so it works fine as long as you change all int types to long or to long long
There are two testcase that fails, couldn't got yet what are they?
There are two testcase that fails, couldn't got yet what are they?
Hi, in the tests 7 and 8 the results are behind int range, so I changed the signature: public static long strangeGrid(int r, int c) and also changed the variable type in the main(): long result = Result.strangeGrid(r, c); All the test are passed now.
def strangeGrid(r, c): # Write your code here # if r is even : if r%2==0: return int(((((r/2-1)*5+c)*2)-1)) else: return int((((((r-1)/2)*5)+c)*2)-2)