int num = 0;
public int kthSmallest(TreeNode root, int k) {
if(root == null) return 0;
if(num == k) return 0;
int left = kthSmallest(root.left,k);
num++;
if(num == k) return root.val;
int right = kthSmallest(root.right,k);
return left  right;
}
Use bit operation to pass result

@taylorzhangyx said in Use bit operation to pass result:
int num = 0;
public int kthSmallest(TreeNode root, int k) {
if(root == null) return 0;
if(num == k) return 0;
int left = kthSmallest(root.left,k);
num++;
if(num == k) return root.val;
int right = kthSmallest(root.right,k);
return left  right;
}Are you sure this will work?
I don't think this can compile.
