Skip to content

Competitive-Coding-10 - #471

Open
paridhimalviya wants to merge 1 commit into
super30admin:masterfrom
paridhimalviya:master
Open

Competitive-Coding-10#471
paridhimalviya wants to merge 1 commit into
super30admin:masterfrom
paridhimalviya:master

Conversation

@paridhimalviya

Copy link
Copy Markdown

-> Length of the word ladder
-> Calculate minimum cost for tickets

@super30admin

Copy link
Copy Markdown
Owner

Interview Problem : Buy and Sell Stock (MinimumCostsForTickets.swift)

It appears you have solved the "Minimum Cost For Tickets" problem instead of the "Buy and Sell Stock" problem. Please ensure you are solving the correct problem. For the "Buy and Sell Stock" problem, you need to maximize profit by buying and selling stocks with the ability to hold at most one share at a time. You can use a greedy approach or dynamic programming to solve it efficiently. I recommend revisiting the problem statement and implementing a solution specifically for that.

VERDICT: NEEDS_IMPROVEMENT


Interview Problem: Peeking Iterator (WordLadder.swift)

It appears there has been a mix-up in the code submission. The problem you were asked to solve is "Peeking Iterator", but the code you provided is for "Word Ladder".

For the Peeking Iterator problem, you need to design a class that wraps an existing iterator and adds a peek functionality. The key idea is to cache the next element so that peek can return it without advancing the iterator.

Here are some tips for implementing PeekingIterator:

  • You should use an instance of the provided iterator and store the next element in a variable (like nextEl).
  • In the constructor, initialize the iterator and set nextEl to the first element by calling next() on the iterator (if it has one).
  • The peek() method should return the cached next element.
  • The next() method should return the cached element and then update the cache to the next element (if available).
  • The hasNext() method should check if the cache is not null.

Please review the problem statement again and implement the correct solution. If you have any questions about the Peeking Iterator problem, feel free to ask.

VERDICT: NEEDS_IMPROVEMENT

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.

2 participants