This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Enter your code here. Read input from STDIN. Print output to STDOUT */ | |
import java.io.*; | |
import java.util.*; | |
class MinMovesSolution | |
{ | |
public static void main(String [] args) throws Exception | |
{ | |
Scanner sc = new Scanner(System.in); | |
String line = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int minPathSum(TreeNode root) { | |
if(root == null) return 0; | |
int sum = root.val; | |
int leftSum = Integer.MAX_VALUE; | |
int rightSum = Integer.MAX_VALUE; | |
if(root.right==null && root.left==null) { | |
return sum; | |
}else{ | |
if(root.left!=null){ |