Skip to content

Fixed small issue #2520

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

Merged
merged 2 commits into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions cpp/0021-merge-two-sorted-lists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,8 @@ class Solution {
return list1;
}

ListNode* head = NULL;
if (list1->val <= list2->val) {
head = list1;
list1 = list1->next;
} else {
head = list2;
list2 = list2->next;
}
ListNode* curr = head;

ListNode* dummy = new ListNode();
ListNode *curr = dummy;
while (list1 != NULL && list2 != NULL) {
if (list1->val <= list2->val) {
curr->next = list1;
Expand All @@ -58,6 +50,6 @@ class Solution {
curr->next = list1;
}

return head;
return dummy->next;
}
};
2 changes: 1 addition & 1 deletion python/0128-longest-consecutive-sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def longestConsecutive(self, nums: List[int]) -> int:
numSet = set(nums)
longest = 0

for n in nums:
for n in numSet:
# check if its the start of a sequence
if (n - 1) not in numSet:
length = 1
Expand Down