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
|
264 Discussions
|
Please Login in order to post a comment
int strangeGrid(int r, int c) { // Base value for the row group (each pair of rows increases base by 10) int base = (r - 1) / 2 * 10;
}
cpp code:
long long strangeGrid(long long r,long long c) { long long result = 0;
}
A solution template for Java is wrong. You should change the return type from int to long,
return r % 2 == 0 ? (10*(r/2 - 1) + 1) + (2*c - 2) : 10*((r+1)/2 - 1) + 2*(c-1)
or
return r % 2 == 0 ? 5*r - 11 + 2*c : 5*r - 7 + 2*c
for c++ must convertt the parsing of int to long long variable and also change stoi() to stoll() i got accepted after this