Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates and expands the multi-language solution set for LeetCode 3043. Find the Length of the Longest Common Prefix within the solution/3000-3099/3043... directory, including synchronizing the README code snippets with the updated implementations.
Changes:
- Optimized the prefix search across several languages by breaking early on the first (longest) matching prefix per
arr2number. - Switched from tracking the best length (
ans) to tracking the best matching prefix value (mx) and deriving the length at the end. - Added a new Rust solution and updated both
README.mdandREADME_EN.mdto include it and reflect code changes.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| solution/3000-3099/3043.Find the Length of the Longest Common Prefix/Solution.ts | Updates TS solution to track mx and compute final length from it. |
| solution/3000-3099/3043.Find the Length of the Longest Common Prefix/Solution.rs | Adds Rust solution using a HashSet of prefixes and mx. |
| solution/3000-3099/3043.Find the Length of the Longest Common Prefix/Solution.py | Updates Python solution to track mx and compute final length once. |
| solution/3000-3099/3043.Find the Length of the Longest Common Prefix/Solution.js | Updates JS solution to track mx and compute final length from it. |
| solution/3000-3099/3043.Find the Length of the Longest Common Prefix/Solution.java | Updates Java solution to track mx and compute final length once. |
| solution/3000-3099/3043.Find the Length of the Longest Common Prefix/Solution.go | Updates Go solution to track mx and compute length via strconv.Itoa(mx). |
| solution/3000-3099/3043.Find the Length of the Longest Common Prefix/Solution.cpp | Updates C++ solution to track mx and compute final length from it. |
| solution/3000-3099/3043.Find the Length of the Longest Common Prefix/README.md | Updates Chinese README snippets (incl. adding Rust snippet) to match implementations. |
| solution/3000-3099/3043.Find the Length of the Longest Common Prefix/README_EN.md | Updates English README snippets (incl. adding Rust snippet) to match implementations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| } | ||
| return ans; | ||
| return mx > 0 ? Math.floor(Math.log10(mx)) + 1 : 0; |
| } | ||
| } | ||
| return ans; | ||
| return mx > 0 ? Math.floor(Math.log10(mx)) + 1 : 0; |
| } | ||
| } | ||
| return ans; | ||
| return mx > 0 ? (int) log10(mx) + 1 : 0; |
| } | ||
| } | ||
| if mx > 0 { | ||
| (mx as f64).log10().floor() as i32 + 1 |
| } | ||
| } | ||
| return ans; | ||
| return mx > 0 ? (int) log10(mx) + 1 : 0; |
| } | ||
| } | ||
| return ans; | ||
| return mx > 0 ? Math.floor(Math.log10(mx)) + 1 : 0; |
| } | ||
| } | ||
| return ans; | ||
| return mx > 0 ? (int) log10(mx) + 1 : 0; |
| } | ||
| } | ||
| } | ||
| return mx > 0 ? Math.floor(Math.log10(mx)) + 1 : 0; |
| } | ||
| } | ||
| if mx > 0 { | ||
| (mx as f64).log10().floor() as i32 + 1 |
| } | ||
| } | ||
| return ans; | ||
| return mx > 0 ? Math.floor(Math.log10(mx)) + 1 : 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.