SHARE
TWEET

Untitled

a guest Apr 21st, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static int[] solution(int N) {
  2.      
  3.      if(N==2) {
  4.          return new int[]{-1,1};
  5.      }
  6.      
  7.      int[] solution = new int[N];
  8.      int sum = 0;
  9.      
  10.      for(int i=0;i<solution.length-1;++i) {
  11.          solution[i]=i;
  12.          sum+=i;
  13.      }
  14.      solution[solution.length-1]=sum*-1;
  15.      
  16.      return solution;
  17.      
  18.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top