GithubHelp home page GithubHelp logo

java-challenge's Introduction

java-challenge

Largest Range

Write a function that takes in an array of integers and returns an array of length 2 representing the largest range of integers contained in that Array.

The first number in the output array should be the first number in the range, while the second number should be the last number in the range.

A range of numbers is defined as a set of numbers that come right after each other in the set of real integers. For instance, the output array [2,6] represents the range {2,3,4,5,6}, which is a range of length 5. Note that numbers don't need to be sorted or adjacent in the imput array in order to form a range.

Sample Input

array = [1, 11, 3, 0 ,15, 5, 2, 4, 10, 7, 12, 6]

Sample Output

[0,7]

Main Class

import java.util.*;

class Program {
  public static int[] largestRange(int[] array) {
    // Write your code here.
    return new int[] {};
  }
}

Test Case 1

{
  "array": [8, 4, 2, 10, 3, 6, 7, 9, 1]
}

Output

{
  [6,10]
}

java-challenge's People

Contributors

diegovirguez avatar

Watchers

 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.