Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javatechie.solution;
- import java.util.Arrays;
- public class FindMissingElementFromArray {
- public static void main(String[] args) {
- int[] array={1,2,3,5};
- int n=array.length+1;
- int mid=n*(n+1)/2;
- int sum= Arrays.stream(array).sum();
- System.out.println(sum-mid);
- }
- }
Add Comment
Please, Sign In to add comment