×

# time limit

 0 how can i reduce its running time, here's the code http://www.codechef.com/viewsolution/2224775 ???? for the question http://www.codechef.com/problems/ARRANGE. asked 10 Jun '13, 19:55 3★aasthi 30●3●5●9 accept rate: 0%

 0 @aasthi >> Well, it was said that The straightforward approach of writing a function that simply reverses the bits of an index to get the new index suffices (recalling that indices with fewer bits than k are padded with leading zeros). The complexity of this algorithm is O(n log n) where n = 2^k is the length of the string. While this was fast enough for the contest, an O(n) algorithm can be devised using a slighly more clever approach.  But still your solution is failing maybe due to slowness of Java or some other reason. You should have a look at how to make this algorithm run in O(n). Here is the editorial for the same. answered 11 Jun '13, 12:01 8.7k●19●48●98 accept rate: 9%
 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:

×717

question asked: 10 Jun '13, 19:55

question was seen: 968 times

last updated: 11 Jun '13, 12:01