perfect hashing data structure in java

Solutions on MaxInterview for perfect hashing data structure in java by the best coders in the world

showing results for - "perfect hashing data structure in java"
Debora
14 Feb 2017
1public int perfectHashFunction(String word) {
2		int key = 0;
3		
4		switch (word) {
5			case "a": key = 0; break;
6			case "after": key = 1; break;
7			case "all": key = 2; break;
8			case "and": key = 3; break;
9			case "because": key = 4; break;
10			case "every": key = 5; break;
11			case "for": key = 6; break;
12			case "from": key = 7; break;
13			case "had": key = 8; break;
14			case "have": key = 9; break;
15			case "in": key = 10; break;
16			case "is": key = 11; break;
17			case "it": key = 12; break;
18			case "its": key = 13; break;
19			case "now": key = 14; break;
20			case "of": key = 15; break;
21			case "on": key = 16; break;
22			case "so": key = 17; break;
23			case "that": key = 18; break;
24			case "the": key = 19; break;
25			case "their": key = 20; break;
26			case "there": key = 21; break;
27			case "to": key = 22; break;
28			case "was": key = 23; break;
29			case "were": key = 24; break;
30			case "which": key = 25; break;
31			case "with": key = 26; break;
32		}
33		return key;
34	}
35