Problem1 added - #472
Conversation
Interview Problem : Buy and Sell Stock (Problem1.py)Your solution is correct and efficient. You have implemented the greedy approach which is optimal for this problem. However, note the following:
Here is a cleaned-up version of your code: class Solution:
def maxProfit(self, prices: List[int]) -> int:
profit = 0
for i in range(1, len(prices)):
if prices[i] > prices[i-1]:
profit += prices[i] - prices[i-1]
return profitVERDICT: PASS Interview Problem: Peeking IteratorIt seems there has been a mix-up in your submission. You have provided a solution for "Best Time to Buy and Sell Stock II" instead of the "Peeking Iterator" problem. For the PeekingIterator problem, you need to design a class that wraps an existing iterator and provides a peek() method that returns the next element without advancing the iterator. The key challenge is to maintain the next element in a variable so that peek() can return it without consuming it. Here are some tips for implementing PeekingIterator:
Please review the problem statement again and try to implement the correct solution. If you need further clarification, feel free to ask. VERDICT: NEEDS_IMPROVEMENT |
No description provided.