Skip to content

Commit 7d2871c

Browse files
committed
#Modification 20
1 parent 010a654 commit 7d2871c

36 files changed

Lines changed: 934 additions & 110 deletions

arrays/Array_Problem_12.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434

3535
public class Array_Problem_12 {
3636

37-
static int arr1[] = new int[] {1, 5 , 9, 10, 15, 20};
38-
static int arr2[] = new int[] {2, 3, 8, 13};
37+
static int[] arr1 = new int[] {1, 5 , 9, 10, 15, 20};
38+
static int[] arr2 = new int[] {2, 3, 8, 13};
3939

4040
static void merge(int m , int n) {
4141

arrays/Array_Problem_13.java

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,4 @@
11
package arrays;
2-
import java.util.*;
3-
4-
/*
5-
* Kadane's Algorithm to find the maxSubarray Sum in O(n)[Linear Time Complexity]
6-
*/
2+
/* Problem Title :-> */
73
public class Array_Problem_13 {
8-
public static void main(String[] args) {
9-
@SuppressWarnings("resource")
10-
Scanner sc = new Scanner(System.in);
11-
int n = sc.nextInt();
12-
int a[] = new int[n];
13-
14-
for(int i=0;i<n;i++)
15-
a[i] = sc.nextInt();
16-
17-
int maxSum = 0;
18-
int currentSum = 0;
19-
20-
for(int i = 0; i < n; i++)
21-
{
22-
currentSum += a[i];
23-
if (currentSum < 0) {
24-
currentSum = 0;
25-
}
26-
maxSum = Math.max(maxSum, currentSum);
27-
28-
System.out.println(maxSum);
29-
}
30-
}
31-
324
}

arrays/Array_Problem_14.java

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,4 @@
11
package arrays;
2-
3-
import java.util.*;
4-
2+
/* Problem Title :-> */
53
public class Array_Problem_14 {
6-
public static void mergeIntervals(Interval a[]) {
7-
if (a.length <= 0) {
8-
return;
9-
}
10-
11-
Stack<Interval> stack = new Stack<>();
12-
Arrays.sort(a.new Comparator<Interval>() {
13-
public int compare(Interval i1, Interval i2) {
14-
return i1.start - i2.start;
15-
}
16-
});
17-
18-
stack.push(a[0]);
19-
}
20-
21-
public static void main(String[] args) {
22-
Interval a[] = new Interval[4];
23-
24-
}
25-
}
26-
27-
/**
28-
* Interval
29-
*/
30-
class Interval {
31-
32-
int start, end;
33-
34-
Interval(int start, int end) {
35-
this.start = start;
36-
this.end = end;
37-
}
384
}

arrays/Array_Problem_15.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package arrays;
2+
/* Problem Title :-> */
3+
public class Array_Problem_15 {
4+
}

arrays/Array_Problem_16.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package arrays;
2+
/* Problem Title :-> */
3+
public class Array_Problem_16 {
4+
}

arrays/Array_Problem_17.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package arrays;
2+
/* Problem Title :-> */
3+
public class Array_Problem_17 {
4+
}

arrays/Array_Problem_18.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
package arrays;
22

3-
/*
4-
* find all pairs on integer array whose sum is equal to given number
5-
* OR
6-
* Equal_Sum_Pairs_of_Array
7-
*/
8-
3+
/* Problem Title :-> find all pairs on integer array whose sum is equal to given number OR Equal_Sum_Pairs_of_Array */
94
public class Array_Problem_18 {
105

116
//function to find & print the sum & elements
12-
static void pairs_value(int iA[], int iN) {
7+
static void pairs_value(int[] iA, int iN) {
138
System.out.println("Pairs of elements & their sum : ");
149

1510
//loop to iterate & find the pair of elements whose sum is equal

arrays/Array_Problem_19.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package arrays;
2+
/* Problem Title :-> */
3+
public class Array_Problem_19 {
4+
}

arrays/Array_Problem_20.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package arrays;
2+
/* Problem Title :-> */
3+
public class Array_Problem_20 {
4+
}

arrays/Array_Problem_21.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package arrays;
2+
/* Problem Title :-> */
3+
public class Array_Problem_21 {
4+
}

0 commit comments

Comments
 (0)