fork download
  1. int sumAtKthLevel(node*root, int k){
  2. int sum=0;
  3. if(root == NULL){
  4. return 0;
  5. }
  6. if(k==1){
  7. sum+=root->data;
  8. return sum;
  9. }
  10. sumAtKthLevel(root->left,k-1);
  11. sumAtKthLevel(root->right,k-1);
  12. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class, interface, or enum expected
int sumAtKthLevel(node*root, int k){
^
Main.java:3: error: class, interface, or enum expected
	if(root == NULL){
	^
Main.java:5: error: class, interface, or enum expected
	}
	^
Main.java:8: error: class, interface, or enum expected
		return sum;
		^
Main.java:9: error: class, interface, or enum expected
	}
	^
Main.java:11: error: class, interface, or enum expected
	sumAtKthLevel(root->right,k-1);
	^
Main.java:12: error: class, interface, or enum expected
}
^
7 errors
stdout
Standard output is empty