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.
defseparateNumbers(s):iflen(s)<=1:print("NO")returnforiinrange(1,len(s)//2+1):#here len(s)//2+1 is important as it create complete iteration len(s)//2 as max size would be len(s)//2 as we need one more no. for the value to be beautifulleftSubArray=s[:i]int_leftSubArray=int(leftSubArray)remainArray=""whilelen(remainArray)<len(s):#create remaining string and compareint_leftSubArray+=1remainArray=remainArray+str(int_leftSubArray)ifremainArray==s[i:]:print("YES",leftSubArray)returnprint("NO")
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 →