Important Programs
Important Programs
return;
}
}
Min Sum:-
public class Solution {
int min = Integer.MAX_VALUE;
public List<List<Integer>> pathSum(TreeNode root, int sum) {
List<Integer> temp = new ArrayList<>();
back(root, temp, 0);
System.out.println(min);
Valid Parenthesis:-
public class Solution {
public boolean isValid(String s) {
Stack<Character> st = new Stack<>();
for(int i = 0; i < s.length(); i++){
char c = s.charAt(i);
if(c == '(')
st.push(')');
else if(c == '[')
st.push(']');
else if(c == '{')
st.push('}');
else if(st.isEmpty() || c != st.pop())
return false;
}
return st.isEmpty();
}
}