You are not logged in. Please login at to post your questions!


TLE in python 3

can anybody suggest me how to overcome time limit in python 3. plzz share any tips . i have come with the best algorithm but still got a time limit for my code.i think my method of input is slow so plzz share a fastest method of input

asked 11 Nov '18, 17:27

itz_pankaj's gravatar image

accept rate: 0%

The fastest method of input is by using... "from sys import stdin" on the top of the code and Wherever you are using the command 'input()' replace it with 'stdin.readline()'.


answered 11 Nov '18, 19:54

harsha_man's gravatar image

accept rate: 0%

edited 11 Nov '18, 19:54

well thanks @harsha_man it works for my code

(12 Nov '18, 12:08) itz_pankaj2★

we can even print the output faster using the 'stdout.write(str(answer))'

(12 Nov '18, 14:35) harsha_man4★

yeah me too!


answered 11 Nov '18, 19:06

nebex's gravatar image

accept rate: 0%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 11 Nov '18, 17:27

question was seen: 248 times

last updated: 12 Nov '18, 14:35