LeetCode Solutions | 501 - 600
503. Next Greater Element II
monotonic stack
510. Inorder Successor in BST II
if curr has right child
if curr is left child, if curr is right child
516. Longest Palindromic Subsequence
dp
if (str[i] == str[j]) {
dp[i][j] = 2 + dp[i + 1][j - 1]
} else {
dp[i][j] = Math.max(dp[i + 1][j], dp[i][j - 1])
}
545. Boundary of Binary Tree
dfs
vector<int> left_boundaries; // push_back
vector<int> leaves; // push_back
deque<int> right_bondaries; // push_front
ret = [root, ...left_boundaries, ...leaves, ...right_bondaries]
556. Next Greater Element III
the same with next_permutation
583. Delete Operation for Two Strings
dp
xs.length + ys.length - 2 * longest_common_subsequence