Someone explain why the simple approach fails here. Thanks...!!!
Can anyone explain why the below approach is failing...\nI am trying to pick a random rectangle first, then within that rect. , trying to generate x and y coord
Can anyone explain why the below approach is failing...\nI am trying to pick a random rectangle first, then within that rect. , trying to generate x and y coordinates within range.\nFails for a very large TC->32.\n\n```\nint rects[][];\n\tint len = 0;\n    public Solution(int[][] rects) {\n    \tthis.rects = rects;\n    \tlen = rects.length;\n    }\n    \n    public int[] pick() {\n    \t\n    \tint p = generateRandomWithinRange(0, len);\n    \t\n    \tint x_str = rects[p][0];\n    \tint x_end = rects[p][2];\n    \tint y_str = rects[p][1];\n    \tint y_end = rects[p][3];\n    \t\n    \treturn new int[]{generateRandomWithinRange(x_str, x_end),generateRandomWithinRange(y_str, y_end)};\n    }\n    \n    public int generateRandomWithinRange(int str, int end) {\n    \t\n    \tif(str == 0 && end == 0)\n    \t\treturn 0;\n    \t\n    \tRandom r = new Random();\n    \tint res = r.nextInt(end-str+1) + str;\n    \treturn  res;\n    }\n    \n```
[]