Skip to content

Conversation

@suryansh098
Copy link
Owner

No description provided.

pullpilot-ai

This comment was marked as outdated.

Repository owner deleted a comment from pullpilot-ai Sep 6, 2025
Repository owner deleted a comment from pullpilot-ai Sep 6, 2025
Repository owner deleted a comment from pullpilot-ai Sep 6, 2025
Copy link

@pullpilot-ai pullpilot-ai left a comment

Choose a reason for hiding this comment

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

This PR adds three C++ implementations for LeetCode problems: longest substring without repeating chars, merge intervals, and peak element. However, there are critical issues: missing #include in the first file, incorrect merging logic in the second, and array index out-of-bounds in the third. These need fixing before the code can be approved.

seen.erase(s[left++]);
}
seen.insert(s[right]);
maxLen = max(maxLen, right - left);

Choose a reason for hiding this comment

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

std::max is used without including . Add ' #include ' to this file.

sort(intervals.begin(), intervals.end());
vector<vector<int>> merged;
for (auto interval : intervals) {
if (merged.empty() || merged.back()[1] < interval[1]) {

Choose a reason for hiding this comment

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

This condition incorrectly handles interval merging; it should check if interval[0] <= merged.back()[1] to decide merging.

int left = 0, right = nums.size();
while (left < right) {
int mid = left + (right - left) / 2;
if (nums[mid] > nums[mid + 1])

Choose a reason for hiding this comment

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

Accessing nums[mid+1] may cause out-of-bounds if mid = nums.size() - 1. Revise the binary search to avoid undefined behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants