Count Good Nodes in Binary Tree
给一个二叉树, 求其中的good node的数量, 一个node被认为是good node,就是从root到它的path中没有比他大的. 求极值, 我用priority queue..只要遍历就可以了
给一个二叉树, 求其中的good node的数量, 一个node被认为是good node,就是从root到它的path中没有比他大的. 求极值, 我用priority queue..只要遍历就可以了
给一个二叉树, 求一条path上的数字能不能通过重新排列组成回文. 因为数字是1-9, 所以直接counting奇数个数即可.
给两个数组, 求两个数组中的同长度的子序列(不是子数组)中最大的dot product. 首先确定dot product是: 通过观察可以看到axbx和ayby是对应的, 并且这题求最值, 所以用dp. let dp[i][j] = the largest dot product of two arrays start with i and j respectively dp[0][0] = the largest dot product of two arrays start with 0 and 0, which is the product of first numbers of two arrays. dp[i][0] (dp[0][j]) is the largest dot product […]
给一个数组, 求其中最小数字的每一位数的和的奇偶.