We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Data Structures
  3. Queues
  4. Truck Tour
  5. Discussions

Truck Tour

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • vinay_star_lord
    7 years ago+ 6 comments

    Easiest approach:

    N=input()

    sumi=0;

    maxi=0;

    j=0;

    for i in range(N):

    a,b=raw_input().split()
    
    sumi+=int(a)-int(b)
    
    if(sumi<0):
    
        sumi=0
    
        j=i+1
    

    print(j)

    8|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature