Skip to content

Instantly share code, notes, and snippets.

@BiruLyu
Created June 5, 2017 16:29
Show Gist options
  • Select an option

  • Save BiruLyu/876c2da2620edbb907ba69dd9e10eb27 to your computer and use it in GitHub Desktop.

Select an option

Save BiruLyu/876c2da2620edbb907ba69dd9e10eb27 to your computer and use it in GitHub Desktop.
//#solution 1
sum[level % 2 == 0 ? 0 : 1] += root.val;
//#solution 2
int a = (level % 2 == 0) ? (sum[0] += root.val) : (sum[1] += root.val);
//#solution 3
if(level % 2 == 0) {
sum[0] += root.val;
} else {
sum[1] += root.val;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment