Skip to content

feat: add solutions to lc problem: No.3558#5252

Merged
yanglbme merged 1 commit into
mainfrom
dev
Jun 11, 2026
Merged

feat: add solutions to lc problem: No.3558#5252
yanglbme merged 1 commit into
mainfrom
dev

Conversation

@yanglbme

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 11, 2026 00:24
@idoocs idoocs added core team Issues or pull requests from core team cpp Issues or Pull requests relate to .cpp code go Issues or Pull requests relate to .go code java Issues or Pull requests relate to .java code md Issues or Pull requests relate to .md files py Issues or Pull requests relate to .py code ts Issues or Pull requests relate to .ts code labels Jun 11, 2026
@yanglbme yanglbme merged commit 25a3f22 into main Jun 11, 2026
8 of 15 checks passed
@yanglbme yanglbme deleted the dev branch June 11, 2026 00:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds multi-language reference solutions and write-ups for LeetCode 3558. Number of Ways to Assign Edge Weights I in the solution/3500-3599 section.

Changes:

  • Added implementations for the same approach (DFS to compute max depth + 2^(d-1) mod M) in Python/Java/C++/Go/TypeScript.
  • Expanded the Chinese and English READMEs with an explanation and code tabs for each language.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
solution/3500-3599/3558.Number of Ways to Assign Edge Weights I/Solution.ts TypeScript implementation of the solution (depth + fast pow).
solution/3500-3599/3558.Number of Ways to Assign Edge Weights I/Solution.py Python implementation of the solution (depth + modular pow).
solution/3500-3599/3558.Number of Ways to Assign Edge Weights I/Solution.java Java implementation of the solution (depth + fast pow).
solution/3500-3599/3558.Number of Ways to Assign Edge Weights I/Solution.go Go implementation of the solution (depth + fast pow).
solution/3500-3599/3558.Number of Ways to Assign Edge Weights I/Solution.cpp C++ implementation of the solution (depth + fast pow).
solution/3500-3599/3558.Number of Ways to Assign Edge Weights I/README.md Chinese explanation + multi-language code tabs.
solution/3500-3599/3558.Number of Ways to Assign Edge Weights I/README_EN.md English explanation + multi-language code tabs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +3 to +7
def dfs(i: int, fa: int = 0) -> int:
res = 0
for j in g[i]:
if j != fa:
res = max(res, dfs(j, i) + 1)
Comment on lines +11 to +15
const dfs = (i: number, fa: number): number => {
let res = 0;
for (const j of g[i]) {
if (j !== fa) {
res = Math.max(res, dfs(j, i) + 1);
Comment on lines +19 to +27
private int dfs(int i, int fa) {
int res = 0;
for (int j : g[i]) {
if (j != fa) {
res = Math.max(res, dfs(j, i) + 1);
}
}
return res;
}
Comment on lines +13 to +22
var dfs func(int, int) int
dfs = func(i, fa int) int {
res := 0
for _, j := range g[i] {
if j != fa {
res = max(res, dfs(j, i)+1)
}
}
return res
}
Comment on lines +14 to +22
auto dfs = [&](this auto&& dfs, int i, int fa) -> int {
int res = 0;
for (int j : g[i]) {
if (j != fa) {
res = max(res, dfs(j, i) + 1);
}
}
return res;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core team Issues or pull requests from core team cpp Issues or Pull requests relate to .cpp code go Issues or Pull requests relate to .go code java Issues or Pull requests relate to .java code md Issues or Pull requests relate to .md files py Issues or Pull requests relate to .py code ts Issues or Pull requests relate to .ts code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants