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

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Dynamic Programming
  4. Abbreviation
  5. Discussions

Abbreviation

Problem
Submissions
Leaderboard
Discussions
Editorial

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

  • keshabkjha
    8 months ago+ 1 comment

    My Code

    def abbreviation(a, b):
        # Write your code here
        dp = [[False for _ in range(len(b)+1)] for _ in range(len(a)+1)]
        dp[0][0] = True
        for i in range(len(a)):
            for j in range(len(b)+1):
                if dp[i][j]:
                    if j < len(b) and a[i].upper() == b[j]:
                        dp[i+1][j+1] = True
                    if a[i].islower():
                        dp[i+1][j] = True
        return 'YES' if dp[len(a)][len(b)] else 'NO'
    
    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy