Add solution for Challenge 21 by alimkinpark - #1640
Conversation
WalkthroughA new Go solution file is added containing three binary search implementations (iterative, recursive, and insertion-position finding) along with a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.11.4)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7b4003b7-5be3-47b2-827f-aba043b6eabb
📒 Files selected for processing (1)
challenge-21/submissions/alimkinpark/solution-template.go
| if arr[mid] < target { | ||
| return BinarySearchRecursive(arr, target, left + 1, right) | ||
| } else { | ||
| return BinarySearchRecursive(arr, target, left, right - 1) |
There was a problem hiding this comment.
Use mid to shrink recursive bounds.
At Line 65 and Line 67, the recursion updates with left + 1 / right - 1 instead of mid + 1 / mid - 1. This breaks binary-search narrowing, increases recursion depth, and can cause stack pressure on large inputs.
Suggested fix
- if arr[mid] < target {
- return BinarySearchRecursive(arr, target, left + 1, right)
- } else {
- return BinarySearchRecursive(arr, target, left, right - 1)
- }
+ if arr[mid] < target {
+ return BinarySearchRecursive(arr, target, mid+1, right)
+ }
+ return BinarySearchRecursive(arr, target, left, mid-1)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if arr[mid] < target { | |
| return BinarySearchRecursive(arr, target, left + 1, right) | |
| } else { | |
| return BinarySearchRecursive(arr, target, left, right - 1) | |
| if arr[mid] < target { | |
| return BinarySearchRecursive(arr, target, mid+1, right) | |
| } | |
| return BinarySearchRecursive(arr, target, left, mid-1) |
|
Could not automatically merge this PR: Resource not accessible by integration A maintainer will need to merge manually. |
1 similar comment
|
Could not automatically merge this PR: Resource not accessible by integration A maintainer will need to merge manually. |
|
👋 Action needed for auto-merge This PR cannot be auto-merged because "Allow edits from maintainers" is enabled. This is a GitHub limitation with automated workflows. To fix: Please uncheck "Allow edits from maintainers" in the PR sidebar (under the reviewers section), and the PR will be auto-merged in the next cycle. Alternatively, a maintainer can merge this manually. |
Challenge 21 Solution
Submitted by: @alimkinpark
Challenge: Challenge 21
Description
This PR contains my solution for Challenge 21.
Changes
challenge-21/submissions/alimkinpark/solution-template.goTesting
Thank you for reviewing my submission! 🚀