Best way to pick index in array randomly in C++?
Difference between en1 and en2, changed 0 character(s)
Hello Codeforces, I was solving the [problem](https://leetcode.com/problems/random-point-in-non-overlapping-rectangles/), and I get the right idea, but there was a problem with choosing the index randomly using `uniform_int_distribution<int>`.↵

[sol1](https://pastebin.com/QLG60DME): This gives me **WA** at test case 32 because I was trying to pick index directly.↵

[sol2](https://pastebin.com/7Sci3Jed): Now, at this time I pick randomly with `lower_bound`, and it **worked**.↵

Is there any better way to choose index uniformly and randomly?↵

**Thanks in advance:)**

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English Naithani 2020-08-22 14:14:16 2 Tiny change: '), and I get the righ' -> '), and I got the righ'
en2 English Naithani 2020-08-22 13:47:31 0 (published)
en1 English Naithani 2020-08-22 13:46:40 624 Initial revision (saved to drafts)