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.

@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.