Giter Site home page Giter Site logo

m-th-to-last-element's Introduction

M-th-to-Last-Element

For this question, you will write a program that, given a positive integer M and a list of integers L, outputs the list element M links away from the end of the list. For this program, we will use 1-indexing. That means mth_to_last(1) is the "1st-to-last" element, or simply the last element in the list. If you are given an invalid index, output NIL instead.

Examples

Input:

4

10 200 3 40000 5

Output:

200

Input:

2

42

Output

NIL

Input Format and Restrictions Each test case will consist of two lines. The first line contains the value of M. The second line contains the values of L, each separated by a space character.

The inputs will always satisfy the following restrictions:

0 < M < 2^32 - 1,

Each element of the list satisfies 0 <= L[i] <= 2^32 - 1,

The number of elements in the list satisfies 0 < |L| < 1024. The bonus test cases may be much larger!

https://www.hackerrank.com/contests/programming-interview-questions/challenges/m-th-to-last-element

m-th-to-last-element's People

Contributors

mirunamd avatar

Stargazers

Minchao Zhu avatar

Watchers

James Cloos 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.