Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

##Unused code

Unused code

for i, num in enumerate(nums):, the i variable is used in your commented code, but commented code shouldn't exist, so i shouldn't exist either.

To come back on the commented code, I hope you didn't submit your solution with these comments as this is a (in my opinion) very bad practice. What does commented code mean after all? These comments could all be replaced by any debugging tool.

##Running time

Running time

(削除) I believe your solution is actually running on \$O(n*\log(n))\$ time as the nested loop doesn't restart at index 1 every time it runs (which is a good thing). (削除ここまで) Seems like this is wrong.

##Code structure

Code structure

Usually, in an interview question code structure is pretty important. Right now you have one method that does everything. You should at least have a method that returns your result and one that prints it. Something like :

def main():
 nums = ...
 k = ...
 print(contigSum(nums, k))
def contigSum(nums, k):
 ...

and contigSum should return the result, not print it.

##Unused code

for i, num in enumerate(nums):, the i variable is used in your commented code, but commented code shouldn't exist, so i shouldn't exist either.

To come back on the commented code, I hope you didn't submit your solution with these comments as this is a (in my opinion) very bad practice. What does commented code mean after all? These comments could all be replaced by any debugging tool.

##Running time

(削除) I believe your solution is actually running on \$O(n*\log(n))\$ time as the nested loop doesn't restart at index 1 every time it runs (which is a good thing). (削除ここまで) Seems like this is wrong.

##Code structure

Usually, in an interview question code structure is pretty important. Right now you have one method that does everything. You should at least have a method that returns your result and one that prints it. Something like :

def main():
 nums = ...
 k = ...
 print(contigSum(nums, k))
def contigSum(nums, k):
 ...

and contigSum should return the result, not print it.

Unused code

for i, num in enumerate(nums):, the i variable is used in your commented code, but commented code shouldn't exist, so i shouldn't exist either.

To come back on the commented code, I hope you didn't submit your solution with these comments as this is a (in my opinion) very bad practice. What does commented code mean after all? These comments could all be replaced by any debugging tool.

Running time

(削除) I believe your solution is actually running on \$O(n*\log(n))\$ time as the nested loop doesn't restart at index 1 every time it runs (which is a good thing). (削除ここまで) Seems like this is wrong.

Code structure

Usually, in an interview question code structure is pretty important. Right now you have one method that does everything. You should at least have a method that returns your result and one that prints it. Something like :

def main():
 nums = ...
 k = ...
 print(contigSum(nums, k))
def contigSum(nums, k):
 ...

and contigSum should return the result, not print it.

added 43 characters in body
Source Link
IEatBagels
  • 12.7k
  • 3
  • 48
  • 99

##Unused code

for i, num in enumerate(nums):, the i variable is used in your commented code, but commented code shouldn't exist, so i shouldn't exist either.

To come back on the commented code, I hope you didn't submit your solution with these comments as this is a (in my opinion) very bad practice. What does commented code mean after all? These comments could all be replaced by any debugging tool.

##Running time

I believe your solution is actually running on \$O(n*\log(n))\$ time as the nested loop doesn't restart at index 1 every time it runs (which(削除) I believe your solution is actually running on \$O(n*\log(n))\$ time as the nested loop doesn't restart at index 1 every time it runs (which is a good thing). (削除ここまで) Seems like this is a good thing)wrong.

##Code structure

Usually, in an interview question code structure is pretty important. Right now you have one method that does everything. You should at least have a method that returns your result and one that prints it. Something like :

def main():
 nums = ...
 k = ...
 print(contigSum(nums, k))
def contigSum(nums, k):
 ...

and contigSum should return the result, not print it.

##Unused code

for i, num in enumerate(nums):, the i variable is used in your commented code, but commented code shouldn't exist, so i shouldn't exist either.

To come back on the commented code, I hope you didn't submit your solution with these comments as this is a (in my opinion) very bad practice. What does commented code mean after all? These comments could all be replaced by any debugging tool.

##Running time

I believe your solution is actually running on \$O(n*\log(n))\$ time as the nested loop doesn't restart at index 1 every time it runs (which is a good thing).

##Code structure

Usually, in an interview question code structure is pretty important. Right now you have one method that does everything. You should at least have a method that returns your result and one that prints it. Something like :

def main():
 nums = ...
 k = ...
 print(contigSum(nums, k))
def contigSum(nums, k):
 ...

and contigSum should return the result, not print it.

##Unused code

for i, num in enumerate(nums):, the i variable is used in your commented code, but commented code shouldn't exist, so i shouldn't exist either.

To come back on the commented code, I hope you didn't submit your solution with these comments as this is a (in my opinion) very bad practice. What does commented code mean after all? These comments could all be replaced by any debugging tool.

##Running time

(削除) I believe your solution is actually running on \$O(n*\log(n))\$ time as the nested loop doesn't restart at index 1 every time it runs (which is a good thing). (削除ここまで) Seems like this is wrong.

##Code structure

Usually, in an interview question code structure is pretty important. Right now you have one method that does everything. You should at least have a method that returns your result and one that prints it. Something like :

def main():
 nums = ...
 k = ...
 print(contigSum(nums, k))
def contigSum(nums, k):
 ...

and contigSum should return the result, not print it.

Source Link
IEatBagels
  • 12.7k
  • 3
  • 48
  • 99

##Unused code

for i, num in enumerate(nums):, the i variable is used in your commented code, but commented code shouldn't exist, so i shouldn't exist either.

To come back on the commented code, I hope you didn't submit your solution with these comments as this is a (in my opinion) very bad practice. What does commented code mean after all? These comments could all be replaced by any debugging tool.

##Running time

I believe your solution is actually running on \$O(n*\log(n))\$ time as the nested loop doesn't restart at index 1 every time it runs (which is a good thing).

##Code structure

Usually, in an interview question code structure is pretty important. Right now you have one method that does everything. You should at least have a method that returns your result and one that prints it. Something like :

def main():
 nums = ...
 k = ...
 print(contigSum(nums, k))
def contigSum(nums, k):
 ...

and contigSum should return the result, not print it.

lang-py

AltStyle によって変換されたページ (->オリジナル) /