Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

combinations in java

private void helper(List<int[]> combinations, int data[], int start, int end, int index) {    
  if (index == data.length) {        
    int[] combination = data.clone();        
    combinations.add(combination);    
  } 
  else if (start <= end) {        
    data[index] = start;        
    helper(combinations, data, start + 1, end, index + 1);        
    helper(combinations, data, start + 1, end, index);    
  }
}
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #combinations #java
ADD COMMENT
Topic
Name
4+7 =