Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement