Hackerrank – Apple and Orange

Hackerrank – Problem Statement

A description of the problem can be found on Hackerrank.

Solution

You need to calculate how many apples or oranges are within given positions on a line. There is a following condition:

    \[(a + a_i \geq s~~and~~ a + a_i \leq t)\]

I created solution in:

All solutions are also available on my GitHub.

Java

JavaScript

Scala

Ruby

Leave a Reply

Your email address will not be published. Required fields are marked *