-
Notifications
You must be signed in to change notification settings - Fork 35
solving test task 1 and 2 #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 submits solutions for two backend developer coding tasks and accompanying documentation.
- Implement run-length encoding with Unicode surrogate pair support.
- Fix thread-safety bug in
BuggyCounterby using atomic operations. - Add solution notes in
SOLUTIONS.md.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| tasks/01-run-length/csharp/Rle.cs | Added Encode implementation handling surrogate pairs. |
| tasks/02-fix-the-bug/csharp/BuggyLib/BuggyCounter.cs | Replaced manual increment + Thread.Sleep(0) with Interlocked.Increment. |
| SOLUTIONS.md | Added solution notes and explanations for both tasks. |
| System.Threading.Thread.Sleep(0); | ||
| _current++; | ||
| return value; | ||
| return Interlocked.Increment(ref _current); |
Copilot
AI
Jun 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interlocked.Increment returns the incremented value, but the original code returned the previous value. If you need to preserve the original ID sequence starting from 0, consider returning Interlocked.Increment(ref _current) - 1 or adjust initialization/tests accordingly.
| return Interlocked.Increment(ref _current); | |
| return Interlocked.Increment(ref _current) - 1; |
| { | ||
| if (prevChar != "") | ||
| { | ||
| result.Append(prevChar + count); |
Copilot
AI
Jun 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This concatenates strings and integers via +, causing an intermediate allocation. Consider using result.Append(prevChar).Append(count); to reduce allocations.
| result.Append(prevChar + count); | |
| result.Append(prevChar).Append(count); |
| } | ||
| if (prevChar != "") | ||
| { | ||
| result.Append(prevChar + count); |
Copilot
AI
Jun 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to above, replace with result.Append(prevChar).Append(count); to avoid creating an extra string.
| result.Append(prevChar + count); | |
| result.Append(prevChar).Append(count); |
Submit coding challenge for backend developer from Hafiz Pangteh