Skip to content

feat: add rust solutions for lc No.2839,2840#5111

Merged
yanglbme merged 2 commits into
mainfrom
dev
Mar 25, 2026
Merged

feat: add rust solutions for lc No.2839,2840#5111
yanglbme merged 2 commits into
mainfrom
dev

Conversation

@yanglbme
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings March 25, 2026 11:17
@idoocs idoocs added java Issues or Pull requests relate to .java code core team Issues or pull requests from core team md Issues or Pull requests relate to .md files py Issues or Pull requests relate to .py code rs Issues or Pull requests relate to .rs code ts Issues or Pull requests relate to .ts code labels Mar 25, 2026
Copy link
Copy Markdown

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

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(
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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(
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@@ -80,7 +80,7 @@ Similar problems:
```python
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
```python
```python
from collections import Counter

Copilot uses AI. Check for mistakes.
@@ -82,7 +82,7 @@ tags:
```python
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
```python
```python
from collections import Counter

Copilot uses AI. Check for mistakes.
@@ -84,7 +84,7 @@ Similar problems:
```python
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
```python
```python
from collections import Counter

Copilot uses AI. Check for mistakes.
@@ -90,7 +90,7 @@ tags:
```python
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
```python
```python
from collections import Counter

Copilot uses AI. Check for mistakes.
@yanglbme yanglbme merged commit b13ed85 into main Mar 25, 2026
@yanglbme yanglbme deleted the dev branch March 25, 2026 13:17
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 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 rs Issues or Pull requests relate to .rs 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