Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jul 24, 2023

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from qqmath July 24, 2023 22:38
if node:
queue.append(node.left)
queue.append(node.right)
queue.extend((node.left, node.right))
Copy link
Author

Choose a reason for hiding this comment

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

Function Solution.isSymmetric refactored with the following changes:

Comment on lines -15 to +22
if token == '+': stack.append(x + y)
if token == '-': stack.append(x - y)
if token == '*': stack.append(x * y)
if token == '/': stack.append(int(x / y))
if token == '*':
stack.append(x * y)
elif token == '+':
stack.append(x + y)
elif token == '-':
stack.append(x - y)
elif token == '/':
stack.append(int(x / y))
Copy link
Author

Choose a reason for hiding this comment

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

Function Solution.evalRPN refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

Comment on lines -4 to +6
for _ in range(index, len(nums2)):
if(nums2[_]>number):
return nums2[_]
return -1
return next(
(nums2[_] for _ in range(index, len(nums2)) if (nums2[_] > number)), -1
)
Copy link
Author

Choose a reason for hiding this comment

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

Function Solution.check refactored with the following changes:

  • Use the built-in function next instead of a for-loop (use-next)

def myPow(self, x: float, n: int) -> float:
if not n: return 1
power = self.myPow(x, int(n/2))
power = self.myPow(x, n // 2)
Copy link
Author

Choose a reason for hiding this comment

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

Function Solution.myPow refactored with the following changes:

ls = s[left]
else:
ls = s[left] + ls + s[right]
ls = s[left] if left==right else s[left] + ls + s[right]
Copy link
Author

Choose a reason for hiding this comment

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

Function Solution.longestPalindrome refactored with the following changes:

Comment on lines -12 to +16
if(s[i]=='('):
if (s[i]=='('):
stack.append(i)
else:
stack.pop()
if(len(stack)==0):
if not stack:
Copy link
Author

Choose a reason for hiding this comment

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

Function Solution.longestValidParentheses refactored with the following changes:

"""
lenz = len(nums)
k = k % lenz
k %= lenz
Copy link
Author

Choose a reason for hiding this comment

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

Function Solution.rotate refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

Comment on lines -18 to +29
# if left half is sorted

# if left half is sorted
if nums[low]<=nums[mid]:
if nums[low]<=target<nums[mid]:
high = mid-1
else:
low = mid+1

# if right half is sorted

elif nums[mid]<target<=nums[high]:
low = mid+1
else:
if nums[mid]<target<=nums[high]:
low = mid+1
else:
high = mid-1
high = mid-1
Copy link
Author

Choose a reason for hiding this comment

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

Function Solution.search refactored with the following changes:

This removes the following comments ( why? ):

# if right half is sorted

Comment on lines -3 to +8
d = dict()
for i in range(len(nums)) :
if nums[i] not in d :
d[nums[i]] = 1
d = {}
for num in nums:
if num not in d:
d[num] = 1
else:
d[nums[i]] += 1
d[num] += 1
Copy link
Author

Choose a reason for hiding this comment

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

Function singleNumber refactored with the following changes:

Comment on lines -51 to +52
dp = [[False]*(n+1) for i in range(m+1)]

dp = [[False]*(n+1) for _ in range(m+1)]
Copy link
Author

Choose a reason for hiding this comment

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

Function Solution.isMatch refactored with the following changes:

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.

1 participant