Skip to content
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

Maria-W #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Maria-W #35

wants to merge 1 commit into from

Conversation

MariaWissler
Copy link

Sorry is a little late, catching up

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

You have some issues on nth_from_end, but otherwise you hit the learning goals here. Nice work

Comment on lines 209 to 228
def find_nth_from_end(n)
raise NotImplementedError
#raise NotImplementedError
current = @head
index = 0

while current != nil && index != n
current = current.next
index += 1

if current == nil
return nil
end

new_current = @head
while current.next != nil
current = current.next
new_current = new_current.next
end
return new_current.data
end

Choose a reason for hiding this comment

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

A couple of things:

  1. Your indentation is off here.
  2. You are missing an end
  3. Even beyond that, it's not working because on empty lists or lists shorter than what's given new_current may end up being nil.

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