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. Algorithms
  3. Implementation
  4. Lisa's Workbook
  5. Discussions

Lisa's Workbook

Problem
Submissions
Leaderboard
Discussions
Editorial

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

  • m_manoj
    5 years ago+ 1 comment

    My Python3 Solution

    n,k = [int(x) for x in input().strip().split()]
    problems_in_chapters = [int(x) for x in input().strip().split()]
    count = 0
    page = 1
    for chapter_problem in problems_in_chapters:
        for current_problem in range(1,chapter_problem + 1):
            if(page == current_problem):
                count = count + 1
            if ((current_problem % k == 0 )or current_problem == chapter_problem):
                page = page + 1
            
    print(count)
    
    16|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature