Git Product home page Git Product logo

puzzapi's Introduction

Endpoints

Binary Trees

URIs:

  • /trees/lca

    Returns the lowest common ancestor (node farthest from the root common to a couple of nodes in the tree)

    POST json format example

     {
     	"tree": "20,8,4,-1,-1,12,10,-1,-1,14,-1,-1,22,-1,-1",
     	"node1": "8",
     	"node2": "4"
     }
    

    Response example

     {
       "lca": "8",
       "exists": True
     }
    

Miscellaneous

/romans

URIs:

  • /romans/iTor

    Converts an integer (base 10) to a roman numeral

    POST json format example

     {
       "number" : "10"
     }
    

    where, number: the integer in base 10

    Response example

     {
       "roman": "X",
     }
    
  • /romans/rToi

    Converts a roman numeral to integer (base 10)

    POST json format example

    {
      "roman" : "CC"
    }
    

    where, roman: the roman numeral to be converted

    Response example

    {
      "number": "200",
    }
    

/sumToTarget

URI: https://puzzapi.herokuapp.com/sumToTarget

Returns a solution to the 2SUM and 3SUM problem.

  • 2SUM: Return a combination of two different indices from a collection of integers whose corresponding elements add up to a target value.

  • 3SUM: Return a combination of three different indicies from a collection of integers whose corresponding elements add up to a target value.

POST json format example

{
  "collection" : "1,2,3,4,5,6",
  "target": "7",
  "mode" : "two"
}

where,

  • collection: is comma seperated list of numbers,

  • target: is the what the sum of the combination should,

  • mode: can take values: "two" (for 2SUM) and "three" (for 3SUM)

Response example

If a solution is found:

{
  "solution": [0,5],
  "exists": true
}

If a solution is not found:

{
  "solution": None,
  "exists": false
}

If something wrong with the input:

{
  "error": "Wrong mode!"
}

puzzapi's People

Watchers

James Cloos avatar Kshitiz Mahajan 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.