Repository navigation
Expand file tree
/
Copy pathMainClass.java
More file actions
87 lines (69 loc) · 1.84 KB
/
Copy pathMainClass.java
File metadata and controls
87 lines (69 loc) · 1.84 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package internalWorkingOfHashMap;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
public class MainClass {
public static void main(String[] args) {
// String s1 = "CAT";
// String s2 = "ACT";
//
// System.out.println(s1.hashCode());
// System.out.println(s2.hashCode());
//
// HashMap<Integer, String> map = new HashMap<>();
//
// map.put(12, "");
// int a[] = {1, 2, 3, 4, 5};
// matrixMultiplication(a.length, a);
int n = 5;
for(int diff = 1; diff<n; diff++) {
for(int row = 0, col = diff; row<n-diff; row++, col++) {
System.out.print(row+""+col+" ");
}
System.out.println();
}
}
static int matrixMultiplication(int n, int a[]){
int dp[][] = new int[n][n];
for(int len = 2; len<n; len++) {
int col = len;
for(int row = 0; row<n-len; row++) {
dp[row][col] = Integer.MAX_VALUE;
for(int k = row+1; k<col; k++) {
dp[row][col] = Math.min(dp[row][col],
dp[row][k] + dp[k][col] +
a[row]*a[k]*a[col]);
}
col++;
}
}
for(int xx[]: dp) {
for(int e: xx) {
System.out.print(e+" ");
}
System.out.println();
}
return dp[0][n-1];
}
}
class Student {
String name;
int rollNo;
boolean enrolled;
List<String> subjects;
@Override
public int hashCode() {
return Objects.hash(rollNo, name, enrolled, subjects);
}
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Student other = (Student) obj;
// return Objects.equals(name, other.name) && rollNo == other.rollNo;
// }
}