摘要:
每个连通块必定有且仅有一个环,且由于每个点的出度均为 11,这样的有向图又叫做内向基环树 题解链接 class Solution { public int maximumInvitations(int[] favorite) { int n = favorite.length; Map<Intege 阅读全文
摘要:
class Solution { public boolean canBeValid(String s, String locked) { int len = s.length(); int numRight = 0, numLeft = 0; // numRight表示不可改变的右括号的数量,nu 阅读全文
摘要:
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ 阅读全文
摘要:
// leetcode 1044class Solution { int p = 13331; int maxn = (int)3e4+5; long[] H = new long[maxn]; // 前i个字符的hashcode long[] P = new long[maxn]; // 次方数组 阅读全文
摘要:
public int strStr(String ss, String pp) { if (pp.isEmpty()) return 0; // 分别读取原串和匹配串的长度 int n = ss.length(), m = pp.length(); // 原串和匹配串前面都加空格,使其下标从 1 开 阅读全文