MCPcopy Create free account
hub / github.com/careercup/ctci / rand

Method rand

java/Chapter 18/Question18_3/Question.java:8–10  ·  view source on GitHub ↗
(int lower, int higher)

Source from the content-addressed store, hash-verified

6
7 /* Random number between lower and higher, inclusive */
8 public static int rand(int lower, int higher) {
9 return lower + (int)(Math.random() * (higher - lower + 1));
10 }
11
12 /* pick M elements from original array. Clone original array so that
13 * we don�t destroy the input. */

Callers 1

pickMRandomlyMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected