Relative Content

Tag Archive for javaarrayscombinationsdistinct

Create distinct list for nCr without repetition

static void printAllkLength(char[] word1, int distinct) { int n=word1.length; printAllkLengthRec(word1,””,n,distinct); } static void printAllkLengthRec(char[] word1, String prefix, int n, int distinct) { if (distinct == 0) { System.out.println(prefix); return; } for (int i = 0; i < n; i++) { String newPrefix = prefix + word1[i]; printAllkLengthRec(word1, newPrefix, n, distinct-1); } } I did the […]