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.
- Prepare
- Mathematics
- Geometry
- Rectangular Game
- Discussions
Rectangular Game
Rectangular Game
Sort by
recency
|
39 Discussions
|
Please Login in order to post a comment
Java :
python code def solve(steps): x = [] y = [] for i in range(n): x.append(steps[i][0]) y.append(steps[i][1]) x1 = min(x) y1 = min(y) result = x1*y1 return result
My Python code, which passed all the test cases:
Python 3 solution:
Basically, we're looking for the smallest area which intersects all the "rectangles" formed by the steps. That'll be the minimum x-length of any rectangle times the minimum y-length of any rectangle. The zip step converts the steps into a list of 2 lists, one with all x-lengths and one with all y-lengths.
Hope that helps!