split array

public boolean splitArray(int[] nums) {
  
  return dividSameSumGroup(0,nums, 0,0);
}

public boolean dividSameSumGroup(int start , int nums[], int sumA, int sumB){
  if( start >= nums.length ){
    if(sumA == sumB)
      return true;
    return false;
  }
  
  if(dividSameSumGroup(start+1, nums, sumA+nums[start], sumB )) return true;
  if(dividSameSumGroup(start+1, nums, sumA, sumB+nums[start] )) return true;
  
  return false;
}

http://codingbat.com/prob/p185204

posted @ 2017-02-14 19:34  友哥  阅读(328)  评论(0编辑  收藏  举报