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

Method rand

java/Chapter 18/Question18_3/QuestionAlternate.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, using only elements 0 through i (inclusive).*/
13 public static int[] pickMRecursively(int[] original, int m, int i) {

Callers 2

pickMRecursivelyMethod · 0.95
pickMIterativelyMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected