Tired of Traffic!
Rohan is a student at UptoSkills Arena, and he's frustrated with the terrible traffic in his city. He wants to find the minimum number of distinct routes he needs to take to visit all his friends' houses. Each friend's house is located at a specific point on a single straight road. Rohan starts at his home, which is at coordinate 0. He can only travel in one direction (positive or negative) at a time. If he visits a friend at coordinate x, he can cover any friend located between his current position and x. He wants to minimize the number of trips he needs to make. A trip ends when he reaches a friend's house and decides to return home to start a new trip.
Input
The first line contains an integer N, the number of Rohan's friends. The next N lines each contain a single integer, the coordinate of a friend's house.
Output
Print a single integer: the minimum number of trips Rohan needs to make.
Constraints
1 <= N <= 1000 -1000 <= coordinate <= 1000 Coordinates are distinct.
Example 1
5 10 20 5 -10 -15
2
Two trips needed: one for positive houses (e.g., to 20) and one for negative houses (e.g., to -15).
Example 2
3 100 200 50
1
Only one trip is needed to cover all positive houses (e.g., to 200).
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
5 10 20 5 -10 -15
3 100 200 50