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.
#!/bin/python3importsysdefseparateNumbers(s):# Complete this functionifs[0]==s:print('NO')returnforiinrange(1,len(s)):mystack=[]mystack.append(s[:i])whilelen(''.join(mystack))<len(s):mystack.append(str(int(mystack[-1])+1))if''.join(mystack)==s:print('YES',mystack[0])breakifi==len(s)-1:print('NO')if__name__=="__main__":q=int(input().strip())fora0inrange(q):s=input().strip()separateNumbers(s)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Separate the Numbers
You are viewing a single comment's thread. Return to all comments →
My solution followed by your idea.