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


time limit

how can i reduce its running time, here's the code ???? for the question

asked 10 Jun '13, 19:55

aasthi's gravatar image

accept rate: 0%

edited 11 Jun '13, 08:26

@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

bugkiller's gravatar image

accept rate: 9%

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: 10 Jun '13, 19:55

question was seen: 971 times

last updated: 11 Jun '13, 12:01