GithubHelp home page GithubHelp logo

golden-triangle-challenge's Introduction

Golden Triangle

A golden triangle has the length of all sides that always less than the sum of the remaining sides.

For example,

  1. a triangle with side lengths 10, 5, 8.
    The following triangle is a golden triangle because
    10 + 5 > 8
    5 + 8 > 10
    8 + 10 > 5

  2. a triangle with side lengths 3, 4, 5.
    The following triangle is a golden triangle because
    3 + 4 > 5
    4 + 5 > 3
    5 + 3 > 4

  3. a triangle with side lengths 3, 4, 20.
    The following triangle is not a golden triangle because
    3 + 4 < 20 *This doesn’t match the condition
    20 + 3 > 4
    4 + 20 > 3

Let T be an array of integers of size N.

N is a positive integer with values >= 0 and <= 100,000.
The values in Array T are in range from −2,147,483,648 to 2,147,483,647.

Example 1
T = [10,2,5,1,8,20]
the function will return true.
due to
T[0]=10, T[2]=(5), T[4]=(8)
can create a golden triangle as explianed in the example above

Example 2
T = [10,50,5,1]
the function will return false
Since there are no values in the array that can create a golden triangle.

Submission:
Write a function to find a golden triangle from aray T (return true or false)

Note:
The time limit is 1 hour, and if the candidate uses more than one for loop, the candidate will lose some scores ( expected program efficiency O(n) )

golden-triangle-challenge's People

Contributors

siriusios avatar kankunnawat 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.