摘要:
最大矩形 dp+单调栈 对每一层维护本列中形成的最高值height,然后对每一层分别计算最大的矩形。 计算每一层最大矩形的时候,先用单调栈记录小于当前位置的左下标和右下标,矩形面积就是(right[i]-left[i]-1) * height[i] class Solution { public i 阅读全文
posted @ 2022-08-16 22:41
xzh-yyds
阅读(22)
评论(0)
推荐(0)
摘要:
两个字符串的最小ASCII删除和 dp dp[i][j]代表s1[0:i]和s2[0:j]两个字符串的最小删除值。转移方程如下: 如果i == 0且j == 0,则dp[i][j] = 0 如果i == 0或j == 0,则dp[i][j] = dp[i-1][j]+s1.charAt(i-1)或d 阅读全文
posted @ 2022-08-16 21:28
xzh-yyds
阅读(37)
评论(0)
推荐(0)
摘要:
质数排列 分别找出质数和合数的数量,将两者的阶乘相乘即可 class Solution { public int numPrimeArrangements(int n) { int cnt = 0; for(int i = 2; i <= n; i++){ boolean flag = true; 阅读全文
posted @ 2022-08-16 20:48
xzh-yyds
阅读(23)
评论(0)
推荐(0)
摘要:
员工的重要性 dfs class Solution { Map<Integer, Employee> map = new HashMap<>(); public int getImportance(List<Employee> employees, int id) { for(Employee e 阅读全文
posted @ 2022-08-16 20:38
xzh-yyds
阅读(18)
评论(0)
推荐(0)
摘要:
移动石子直到连续 分类讨论 class Solution { public int[] numMovesStones(int a, int b, int c) { if(a > b){int t = a; a = b; b = t;} if(a > c){int t = a; a = c; c = 阅读全文
posted @ 2022-08-16 20:22
xzh-yyds
阅读(16)
评论(0)
推荐(0)
摘要:
设计有序流 数组遍历 维护一个String数组和一个index下标,如果insert插入的idKey-1==index,则将后续字符串依次输出直到遇到null或index==n为止 class OrderedStream { String arr[]; int index = 0; public O 阅读全文
posted @ 2022-08-16 19:25
xzh-yyds
阅读(23)
评论(0)
推荐(0)

浙公网安备 33010602011771号