Challenge problem

can anyone tell me what is wrong in this code?

import java.util.*;

public class Main {

static Scanner scn = new Scanner(System.in);
public static void main(String args[]) {
	int t = scn.nextInt();
	if (t >= 1 && t <= 20) {
		for (int i = 0; i < t; i++) {
			int n = scn.nextInt();
			int[] arr = null;
			if (n >= 1 && n <= 100000) {
				arr = new int[n];
				arr = take_input(arr);
			}
			maximum_subarray_sum(arr);
		}
	}
}
public static int[] take_input(int[] arr) {
	// int n = scn.nextInt();
	// int[] arr = new int[n];
	for (int i = 0; i < arr.length; i++) {
		int tmp = scn.nextInt();
		if (tmp >= -100000000 && tmp <= 100000000) {
			arr[i] = tmp;
		}
	}
	return arr;
}

public static void maximum_subarray_sum(int[] arr) {
	int sum = 0;
	for (int i = 0; i < arr.length; i++) {
		if (arr[i] < 0) {
			arr[i] = 0;
		}
	}
	for (int i = 0; i < arr.length; i++) {
		sum = sum + arr[i];
	}
	System.out.println(sum);
}

}

@VinayakSingh11111
Lemme check bro!

@VinayakSingh11111 The approach is completely incorrect, how can you modify the array?
This question will be done by kadane’s algorithm, if you don’t know about it then study about it.
The example test case:-
1
8
-2 -5 6 -2 -3 1 5 -6
output should be 7 yours is 12 because what you just did is converted negative number to 0 and then summing all, actually you have to find subarray i. continous elements that have max sum.

If your query is resolved then close it by marking it resolved.