Conversation
There was a problem hiding this comment.
Pull request overview
Adds Rust implementations for LeetCode 2839 and 2840 and refactors existing solutions/snippets to use simpler equality checks.
Changes:
- Added Rust solutions for LC 2839 and 2840.
- Simplified TypeScript solutions by replacing manual loops with
every(...)checks. - Updated Python solutions and READMEs to use
Counter(...)-based comparisons.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| solution/2800-2899/2840.Check if Strings Can be Made Equal With Operations II/Solution.ts | Refactors validation to cnt.every(...) for concise zero-checking |
| solution/2800-2899/2840.Check if Strings Can be Made Equal With Operations II/Solution.rs | Adds Rust solution using parity buckets and frequency deltas |
| solution/2800-2899/2840.Check if Strings Can be Made Equal With Operations II/Solution.py | Switches to Counter comparisons for parity slices |
| solution/2800-2899/2840.Check if Strings Can be Made Equal With Operations II/Solution.java | Formatting-only adjustment at file end |
| solution/2800-2899/2840.Check if Strings Can be Made Equal With Operations II/README_EN.md | Updates snippets (Python uses Counter, TS simplified) and adds Rust snippet |
| solution/2800-2899/2840.Check if Strings Can be Made Equal With Operations II/README.md | Same as above for non-English README |
| solution/2800-2899/2839.Check if Strings Can be Made Equal With Operations I/Solution.ts | Refactors validation to cnt.every(...) for concise zero-checking |
| solution/2800-2899/2839.Check if Strings Can be Made Equal With Operations I/Solution.rs | Adds Rust solution using parity buckets and frequency deltas |
| solution/2800-2899/2839.Check if Strings Can be Made Equal With Operations I/Solution.py | Switches to Counter comparisons for parity slices |
| solution/2800-2899/2839.Check if Strings Can be Made Equal With Operations I/README_EN.md | Updates snippets (Python uses Counter, TS simplified) and adds Rust snippet |
| solution/2800-2899/2839.Check if Strings Can be Made Equal With Operations I/README.md | Same as above for non-English README |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| class Solution: | ||
| def canBeEqual(self, s1: str, s2: str) -> bool: | ||
| return sorted(s1[::2]) == sorted(s2[::2]) and sorted(s1[1::2]) == sorted( | ||
| return Counter(s1[::2]) == Counter(s2[::2]) and Counter(s1[1::2]) == Counter( |
There was a problem hiding this comment.
Counter is used but not imported in this file, which will raise a NameError at runtime. Add from collections import Counter at the top (or qualify the reference appropriately) so the solution runs.
| class Solution: | ||
| def checkStrings(self, s1: str, s2: str) -> bool: | ||
| return sorted(s1[::2]) == sorted(s2[::2]) and sorted(s1[1::2]) == sorted( | ||
| return Counter(s1[::2]) == Counter(s2[::2]) and Counter(s1[1::2]) == Counter( |
There was a problem hiding this comment.
Counter is used but not imported in this file, which will raise a NameError at runtime. Add from collections import Counter at the top (or qualify the reference appropriately) so the solution runs.
| @@ -80,7 +80,7 @@ Similar problems: | |||
| ```python | |||
There was a problem hiding this comment.
The README Python snippet now uses Counter but doesn’t show the required import (from collections import Counter). Update the snippet to include the import so readers can run it as-is.
| ```python | |
| ```python | |
| from collections import Counter |
| @@ -82,7 +82,7 @@ tags: | |||
| ```python | |||
There was a problem hiding this comment.
The README Python snippet now uses Counter but doesn’t show the required import (from collections import Counter). Update the snippet to include the import so readers can run it as-is.
| ```python | |
| ```python | |
| from collections import Counter |
| @@ -84,7 +84,7 @@ Similar problems: | |||
| ```python | |||
There was a problem hiding this comment.
The README Python snippet now uses Counter but doesn’t show the required import (from collections import Counter). Update the snippet to include the import so readers can run it as-is.
| ```python | |
| ```python | |
| from collections import Counter |
| @@ -90,7 +90,7 @@ tags: | |||
| ```python | |||
There was a problem hiding this comment.
The README Python snippet now uses Counter but doesn’t show the required import (from collections import Counter). Update the snippet to include the import so readers can run it as-is.
| ```python | |
| ```python | |
| from collections import Counter |
No description provided.