Created
December 6, 2021 10:09
-
-
Save abhisheks-12/f0a565752384395fda81ec87608ea0f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
// Bhava nahi aathavt java try kar | |
public class Main { | |
public static void main(String[] args) throws Exception { | |
// write your code here | |
Scanner scn = new Scanner(System.in); | |
int n1 = scn.nextInt(); | |
int arr1[] = new int[n1]; | |
for (int i = 0; i < arr1.length; i++) { | |
arr1[i] = scn.nextInt(); | |
} | |
int arr2[] = {} | |
for (int i = 0; i < arr1.length; i++) { | |
if (i == 0) { | |
arr2.push(arr[0]); | |
} | |
if (i == 1) { | |
int sub = arr[1] - arr[0]; | |
// console.log(sub); | |
arr2.push(sub); | |
} | |
if (i == 2) { | |
arr2.push(0); | |
} | |
if (i == 3) { | |
int sub2 = arr[3] - arr[2]; | |
arr2.push(sub); | |
} | |
} | |
int sum = 0; | |
for (int i = 0; i < arr2.length; i++) { | |
sum += arr[i]; | |
} | |
System.out.println(sum) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment