File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 55
66public class ArrayListExample {
77 public static void main (String [] args ) {
8+
9+ ArrayList <Integer > list_1 = new ArrayList <>();
10+ list_1 .add (17 );
11+ list_1 .add (28 );
12+ list_1 .add (30 );
13+
14+ ArrayList <Integer > list_2 = new ArrayList <>();
15+ list_2 .add (99 );
16+ list_2 .add (16 );
17+ list_2 .add (8 );
18+ compareTriplets (list_1 ,list_2 );
19+
820 //Syntax
921 ArrayList <Integer > list = new ArrayList <>();
1022 list .add (34 );
@@ -22,6 +34,26 @@ public static void main(String[] args) {
2234
2335 ArrayList <Integer > list1 = solve (list );
2436 System .out .println (list1 );
37+ }
38+
39+ public static List <Integer > compareTriplets (List <Integer > a , List <Integer > b ) {
40+
41+ // List<Integer> resultList = new List<Integer>();
42+
43+ List <Integer > list = new ArrayList <Integer >(2 );
44+ list .add (0 );
45+ list .add (0 );
46+ for (int i = 0 ; i <a .size ();i ++){
47+ if (a .get (i ) > b .get (i )){
48+ int count = list .get (0 );
49+ list .set (0 , count +1 );
50+ }else if (a .get (i ) < b .get (i )){
51+ int count = list .get (1 );
52+ list .set (1 , count +1 );
53+ }
54+ }
55+
56+ return list ;
2557
2658 }
2759
You can’t perform that action at this time.
0 commit comments