Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. public boolean splitArray(int[] nums) {
  2. switch(nums.length) {
  3. case 0:
  4. return true;
  5. case 1:
  6. return false;
  7. }
  8.  
  9. int sum = sum(nums, nums.length - 1);
  10. if(sum % 2 != 0)
  11. return false;
  12. return true;
  13. }
  14. public int sum(int[] a, int n) {
  15. if (n == 0)
  16. return a[n];
  17. else
  18. return a[n] + sum(a, n-1);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement