fork download
  1. # your code goes here
  2.  
  3. class Solution:
  4. def smallestSubstring(self, s:str) -> str:
  5. result = ''
  6. i,j = 0,0
  7.  
  8. for i in range(len(s)):
  9. result += s[i]
  10. temp = ''
  11. for j in range(len(s)):
  12. if (len(temp) == len(s)):
  13. break
  14. temp += result
  15. if (temp == s):
  16. break
  17. return result
  18.  
  19. if __name__ == '__main__':
  20. s = Solution()
  21. inp = input()
  22. print(s.smallestSubstring(inp))
  23.  
Success #stdin #stdout 0.12s 14112KB
stdin
abcabcabcabc
stdout
abc