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. Dynamic Programming
  4. Requirement
  5. Discussions

Requirement

Problem
Submissions
Leaderboard
Discussions
Editorial

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

  • taylorleebiz
    6 years ago+ 2 comments

    My interpretation, using the sample input for explanation:

    From the sample input, n=6 and m=7.

    I'm using array convention, where a[0] is left most value and a[5] is right most value.

    a[0] can be any digit from 0 to 9. Same for indices 1 through 5.

    Therefore, you can think of the possible values of a as: [0,0,0,0,0,0] all the way to [9,9,9,9,9,9].

    Another way to think about this is, we are considering the range of numbers from 0 to (10**n)-1

    The number 654321 is in this range. Does 654321 fit all m requirements? m={(1 3),(0 1),(2 4),(0 4),(2 5),(3 4),(0 2)}

    m[1] = (0 1) => requirement that value@index0 <= value@index1

    For 654321, value@index0 is 6 and value@index1 is 5.

    Therefore, requirement m[1] is not met, so 654321 is not a valid assignment.

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