Skip to content

Conversation

@yanglbme
Copy link
Member

@yanglbme yanglbme commented Jan 5, 2026

No description provided.

Copilot AI review requested due to automatic review settings January 5, 2026 13:54
@idoocs idoocs added core team Issues or pull requests from core team cpp Issues or Pull requests relate to .cpp code java Issues or Pull requests relate to .java code md Issues or Pull requests relate to .md files ts Issues or Pull requests relate to .ts code labels Jan 5, 2026
@yanglbme yanglbme merged commit 2f934c0 into main Jan 5, 2026
9 checks passed
@yanglbme yanglbme deleted the dev branch January 5, 2026 13:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a TypeScript solution for LeetCode problem 1977 ("Number of Ways to Separate Numbers") and refactors the Java and C++ solutions to move constant declarations inside the method scope.

Key Changes:

  • Added a new TypeScript implementation of the dynamic programming algorithm
  • Refactored Java and C++ solutions to use local constant declarations instead of class-level constants
  • Updated documentation files to include the TypeScript solution

Reviewed changes

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

Show a summary per file
File Description
Solution.ts New TypeScript solution implementing the dynamic programming algorithm with LCP preprocessing
Solution.java Refactored to move mod constant from class-level to method scope
Solution.cpp Refactored to move mod constant from class-level to method scope
README_EN.md Added TypeScript code example to English documentation
README.md Added TypeScript code example to Chinese documentation

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

}
}

function cmp(i: number, j: number, k: number): boolean {
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The function name 'cmp' is ambiguous. Consider renaming it to something more descriptive like 'isLexicographicallyGreaterOrEqual' or 'compareSubstrings' to clarify its purpose of comparing substrings lexicographically.

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +33
let v: number = 0;
if (num[i - j] !== '0') {
if (i - j - j >= 0 && cmp(i - j, i - j - j, j)) {
v = dp[i - j][j];
} else {
v = dp[i - j][Math.min(j - 1, i - j)];
}
}
dp[i][j] = (dp[i][j - 1] + v) % mod;
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The variable name 'v' is not descriptive. Consider renaming it to something more meaningful like 'validWays' or 'count' to indicate it represents the number of valid ways at this position.

Suggested change
let v: number = 0;
if (num[i - j] !== '0') {
if (i - j - j >= 0 && cmp(i - j, i - j - j, j)) {
v = dp[i - j][j];
} else {
v = dp[i - j][Math.min(j - 1, i - j)];
}
}
dp[i][j] = (dp[i][j - 1] + v) % mod;
let validWays: number = 0;
if (num[i - j] !== '0') {
if (i - j - j >= 0 && cmp(i - j, i - j - j, j)) {
validWays = dp[i - j][j];
} else {
validWays = dp[i - j][Math.min(j - 1, i - j)];
}
}
dp[i][j] = (dp[i][j - 1] + validWays) % mod;

Copilot uses AI. Check for mistakes.
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 java Issues or Pull requests relate to .java code md Issues or Pull requests relate to .md files ts Issues or Pull requests relate to .ts code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants