GithubHelp home page GithubHelp logo

samuelbanya / phase-4-data-structures-singly-linked-list-return-node Goto Github PK

View Code? Open in Web Editor NEW

This project forked from learn-co-curriculum/phase-4-data-structures-singly-linked-list-return-node

0.0 0.0 0.0 7 KB

License: Other

Ruby 100.00%

phase-4-data-structures-singly-linked-list-return-node's Introduction

Singly Linked List Return Node Lab

Learning Goals

  • Build a Singly Linked List and use it to solve an algorithm

Introduction

Now that we have learned to build out our LinkedList and Node classes, as well as implemented some common methods to get a feel for working with linked lists, let's use our Singly Linked List to solve an algorithm!

Fork and clone this lab; you'll be coding in the lib folder. You can run the tests at any point using learn test to check your work.

Instructions

Write a method #nth_from_end that takes a number n and returns the value at the nth node from the end of the linked list. If the nth node does not exist, return nil.

For example, when given a linked list 3 -> 2 -> 1:

  • When n = 1, return 1 (the element at the end of the list)
  • When n = 3, return 3 (the third element from the end)
  • When n = 4, return nil (since 4 is greater than the length of the list)

phase-4-data-structures-singly-linked-list-return-node's People

Contributors

ihollander avatar graciemcguire avatar samuelbanya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.