|
| 1 | +### Question {#question} |
| 2 | + |
| 3 | +[https://leetcode.com/problems/random-point-in-non-overlapping-rectangles/description/](https://leetcode.com/problems/random-point-in-non-overlapping-rectangles/description/) |
| 4 | + |
| 5 | +Given a list of non-overlapping axis-aligned rectangles rects, write a function pick which randomly and uniformily picks an integer point in the space covered by the rectangles. |
| 6 | + |
| 7 | +**Note:** |
| 8 | + |
| 9 | +1. An integer point is a point that has integer coordinates. |
| 10 | +2. A point on the perimeter of a rectangle is included in the space covered by the rectangles. |
| 11 | +3. ith rectangle = rects\[i\] = \[x1,y1,x2,y2\], where \[x1, y1\] are the integer coordinates of the bottom-left corner, and \[x2, y2\] are the integer coordinates of the top-right corner. |
| 12 | +4. length and width of each rectangle does not exceed 2000. |
| 13 | +5. 1 <= rects.length <= 100 |
| 14 | +6. pick return a point as an array of integer coordinates \[p\_x, p\_y\] |
| 15 | +7. pick is called at most 10000 times. |
| 16 | + |
| 17 | +**Example 1:** |
| 18 | + |
| 19 | +``` |
| 20 | +Input: |
| 21 | +["Solution","pick","pick","pick"] |
| 22 | +[[[[1,1,5,5]]],[],[],[]] |
| 23 | +Output: |
| 24 | +[null,[4,1],[4,1],[3,3]] |
| 25 | +``` |
| 26 | + |
| 27 | +**Example 2:** |
| 28 | + |
| 29 | +``` |
| 30 | +Input: |
| 31 | +["Solution","pick","pick","pick","pick","pick"] |
| 32 | +[[[[-2,-2,-1,-1],[1,0,3,0]]],[],[],[],[],[]] |
| 33 | +Output: |
| 34 | +[null,[-1,-2],[2,0],[-2,-1],[3,0],[-2,-2]] |
| 35 | +``` |
| 36 | + |
| 37 | +**Explanation of Input Syntax:** |
| 38 | + |
| 39 | +The input is two lists: the subroutines called and their arguments. Solution's constructor has one argument, the array of rectangles rects. pick has no arguments. Arguments are always wrapped with a list, even if there aren't any. |
| 40 | + |
| 41 | +### Thought Process {#thought-process} |
| 42 | + |
| 43 | +1. asd |
| 44 | + |
| 45 | +### Solution |
| 46 | + |
| 47 | +```java |
| 48 | + |
| 49 | +``` |
| 50 | + |
| 51 | +### Additional {#additional} |
| 52 | + |
| 53 | + |
| 54 | + |
|
0 commit comments