×

# turbo sort TLE

 0 hey i'm getting tle (time limit exceeded) for the following code the problem is http://www.codechef.com/problems/TSORT/ itr = int(raw_input()) arr = [] for i in xrange(0,itr): inp = int(raw_input()) arr.append(inp) arr.sort() for i in xrange(0,itr): print arr[i]  im not getting the problem in it pls help........ Thanx.... asked 23 Jul '14, 14:53 2★dpmittal 26●1●1●5 accept rate: 0%

 0 actually this qus requires O(n) sorting algorithm, take a look at the constraints for N, you can use count sort :) answered 23 Jul '14, 17:23 -2●3 accept rate: 0%
 -1 The i/p o/p speed of python is not great combined that with you using the sort function with an average time complexity of nlogn. Maybe the nlogn implementation can work in c/c++ with faster i/p & o/p but not in this implementation of python at least. Try reading about counting sort. Hope that helps :) answered 23 Jul '14, 15:37 288●2●4●11 accept rate: 6%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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:

×243
×121

question asked: 23 Jul '14, 14:53

question was seen: 911 times

last updated: 23 Jul '14, 17:23