更多资源与服务
想要了解更多编程面试技巧,或者需要专业的面试辅导、OA代做、简历润色等服务?我们提供全方位的求职面试支持,帮助您在大厂面试真题、系统设计面试和算法面试中脱颖而出,轻松拿到心仪的 offer!无论您是留学生、刚踏入职场的新人,还是需要代码优化建议的开发者,我们的团队由ACM奖牌得主、大厂资深 TLM 及经验丰富的行业老兵组成,确保为您提供最专业的指导。
扫描下方二维码,添加我们的微信,获取更多服务:

关键词:
- 面试代面
- 代码代写
- OA代做
- 面试技巧
- 面试经验分享
- 职业规划
- 编程练习
让我们帮助您在技术面试中脱颖而出,实现职业上的飞跃!
Question 1: Counting Creator Communities
Description:
In a social network, there are multiple creators, and each one may be associated with others, forming a network community. Given an association matrix
related, where related[i][j] == '1' indicates that creator i and j are associated (they belong to the same community), and related[i][j] == '0' indicates no association.
Two creators are considered to be in the same community if they are directly or indirectly connected. For instance, if i is connected to j, and j is connected to k, then i, j, and k belong to the same community.
Implement a function to count and return the total number of communities in the social network.
Input:
related(List[List[str]]): Ann x nmatrix representing associations, whererelated[i][j]is either'1'or'0', andrelated[i][i]is always'1'.
Output:
- Returns an integer, the number of communities in the network.
Code Example:
class UF:
def __init__(self, size):
self.parent = list(range(size))
def find(self, x):
if self.parent[x] != x:
self.parent[x] = self.find(self.parent[x])
return self.parent[x]
def merge(self, x, y):
px, py = self.find(x), self.find(y)
self.parent[px] = py
def countCreatorCommunities(related):
n = len(related)
uf = UF(n)
for i in range(n):
for j in range(i+1, n):
if related[i][j] == '1':
uf.merge(i, j)
ds = set()
for i in range(n):
ds.add(uf.find(i))
return len(ds)
Question 2: Counting Good Arrays
Description:
Given an integer array
arr, where some elements are 0, and other elements are positive integers, write a function to compute the number of “good arrays”. An array is considered a “good array” if it meets specific conditions, including:
- Elements in
arrcan be consecutive0s or some non-zero integers. - The count of consecutive
0s meeting specific conditions can generate valid subarrays.
The function should consider the position of these 0s and how they interact with neighboring non-zero numbers to fulfill the “good array” definition.
Input:
arr(List[int]): An array of integers with some elements as0and others as positive integers.
Output:
- Returns the number of “good arrays” that meet the criteria, with the result modulo
10^9 + 7.
Code Example:
def countGoodArrays(arr):
n = len(arr)
dp = [[0] * (n+1) for _ in range(n)]
mod = 10**9 + 7
dp[0][0] = 1
for i in range(1, n):
dp[i][0] = 2 * dp[i-1][1] + dp[i-1][0]
for j in range(1, i + 1):
dp[i][j] = dp[i-1][j-1] + dp[i-1][j] + dp[i-1][j+1]
dp[i][j] %= mod
res = 1
sb = False
prev = -1
eb = False
c = 0
for i, x in enumerate(arr):
if x == 0:
c += 1
else:
eb = True
if not sb or not eb:
res *= 3**c
res %= mod
else:
if c > 0 and abs(x - arr[prev]) > c + 1:
return 0
res *= (dp[c][abs(x - arr[prev])] +
dp[c][abs(abs(x - arr[prev]) - 1)] +
dp[c][abs(x - arr[prev]) + 1])
res %= mod
sb = True
c = 0
prev = i
if c > 0:
res *= 3**c
res %= mod
return res
🎯 面试代面 / OA辅助 — 前大厂工程师团队帮你上岸
正在为技术面试发愁?我们的北美大厂工程师团队提供专业辅导和辅助服务:
- OA代做 — HackerRank / CodeSignal / LeetCode 等全平台覆盖,保证通过
- 视频代面 — Google / Meta / Amazon 等主流平台,真实面试官在线
- 模拟面试 — 1对1真实场景还原,详细反馈与改进建议
- 简历优化 — 北美大厂HR背景,帮你打造高通过率简历
📱 微信: leetcode-king(添加请备注”面试”,回复更快)
💬 Telegram: @ayinterview(24小时在线)
⚡ 紧急面试可加急,30分钟内安排工程师对接
🚀 需要面试辅导?立即联系我们
✅ 前大厂工程师团队 · 一对一辅导 · 真实案例 · 保密协议
微信: leetcode-king | Telegram: @ayinterview
💼 北美科技大厂面试 · 面试代面 · OA辅助 · VO辅助