sahkumar.bishwash's blog

By sahkumar.bishwash, history, 7 months ago, In English

PyPy 3-64 Submission id 261912327 Python 3 Submission id 261912035. Spent all my time debugging this code but could not figure out during contest.

  • Vote: I like it
  • +11
  • Vote: I do not like it

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by sahkumar.bishwash (previous revision, new revision, compare).

»
7 months ago, # |
  Vote: I like it +35 Vote: I do not like it

Inside of your solve function, these lines are technically O(n^2) since string concatenation is O(n) in python.

    ans = ""
    for i in s:
        ans += dic[i]
    print(ans) 

However, the compiler that python3 uses optimizes it to O(n) but pypy3's doesn't. I would recommend just adding each character to a list and joining them at the end with .join().