-
Notifications
You must be signed in to change notification settings - Fork 77
[AREV-314] (ignore) incremental review test demo github prod #1884
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,60 @@ | ||||||
| def two_sum(nums, target): | ||||||
| seen = {} | ||||||
|
|
||||||
| for i, num in enumerate(nums): | ||||||
| complement = target - num | ||||||
|
|
||||||
| if complement in seen: | ||||||
| return [seen[complement], i] | ||||||
|
|
||||||
| seen[num] = num | ||||||
|
|
||||||
| return [] | ||||||
|
|
||||||
|
|
||||||
| class ListNode: | ||||||
| def __init__(self, val=0, next=None): | ||||||
| self.val = val | ||||||
| self.next = next | ||||||
|
|
||||||
|
|
||||||
| def reverse_linked_list(head): | ||||||
| prev = None | ||||||
| current = head | ||||||
|
|
||||||
| while current: | ||||||
| next_node = current.next | ||||||
| current.next = prev | ||||||
| prev = current | ||||||
| current = next_node | ||||||
|
|
||||||
| return current | ||||||
|
|
||||||
|
|
||||||
| def is_valid_parentheses(s): | ||||||
| stack = [] | ||||||
| mapping = {')': '(', '}': '{', ']': '['} | ||||||
|
|
||||||
| for char in s: | ||||||
| if char in mapping: | ||||||
| top = stack.pop() if stack else '#' | ||||||
| if mapping[char] != top: | ||||||
| return False | ||||||
| else: | ||||||
| stack.append(char) | ||||||
|
|
||||||
| return True | ||||||
|
|
||||||
|
|
||||||
| def climb_stairs(n): | ||||||
| if n <= 1: | ||||||
| return n | ||||||
|
|
||||||
| dp = [0] * (n + 1) | ||||||
| dp[0] = 1 | ||||||
| dp[1] = 1 | ||||||
|
|
||||||
| for i in range(2, n + 1): | ||||||
| dp[i] = dp[i - 1] + dp[i - 2] | ||||||
|
|
||||||
| return dp[n - 1] | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔥 Code BugsThe function returns Details📖 Explanation: The dp table is computed correctly up to index n, but the final return uses n-1, which gives the answer for n-1 stairs instead of n stairs.
Suggested change
|
||||||
Uh oh!
There was an error while loading. Please reload this page.