-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreeSum.java
More file actions
executable file
·35 lines (32 loc) · 1002 Bytes
/
ThreeSum.java
File metadata and controls
executable file
·35 lines (32 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Neel_Kapadia
*/
import java.util.Arrays;
public class ThreeSum {
public static void printPermutations(int[] n, int[] Nr, int idx) {
if (idx == n.length) { //stop condition for the recursion [base clause]
//System.out.println(Arrays.toString(n));
return;
}
for (int i = 0; i <= Nr[idx]; i++) {
n[idx] = i;
printPermutations(n, Nr, idx+1); //recursive invokation, for next elements
}
}
public static void main(String[] args) {
/* let n.length == 3 and Nr[0] = 2, Nr[1] = 3, Nr[2] = 3 */
int[] n = new int[4];
int Nr[] = {2,3,3,4};
printPermutations(n, Nr, 0);
String s = "hello";
String s1 = "world";
String [] s2 = {s,s1};
System.out.println(s2[s2.length-1].length());
}
}