[BangPypers] SPOJ : PALIN problem ...

2014-11-11 Thread Avinash
​Hi pals, I need littele help .. I made a program as per the given discription in the problem but when I submit it , Spoj is not accepting it . Can anyone tell me where I am doing wrong ! here is the problem set: http://www.spoj.com/problems/PALIN/ and here is my solution: ​​N=int(raw_input()) i

Re: [BangPypers] SPOJ : PALIN problem ...

2014-11-11 Thread Kishor Bhat
Hi Avinash, I'd like to point out that the problem statement says that the given integer K has at max 10 ^ 6 digits. This does not mean that K is bounded by 10 ^ 6 ! Someone else correct me if I'm wrong, but I don't think this approach will hold for such large inputs. Regards, Kishor Bhat On Tu

Re: [BangPypers] SPOJ : PALIN problem ...

2014-11-11 Thread Nikhileshkumar Ikhar
I see 2 potential problems. 2nd raw_input is surrounded by (), is it correct? In if condition conversion to list is not required. Also instead of converting to string u can take difference of number and reversed number. U can use tools like http://www.pythontutor.com/visualize.html#mode=edit For

Re: [BangPypers] SPOJ : PALIN problem ...

2014-11-11 Thread Nikhileshkumar Ikhar
Hi Kishor, 10^6 is upper limit n is not a huge value. Memory footprint won't be high because we need to find only next palindrome number. Or if required for loop should be replaced with incremental while loop. Let me know ur thoughts. Regards, Nikhil On 11 Nov 2014 22:11, "Kishor Bhat" wrote: >

Re: [BangPypers] SPOJ : PALIN problem ...

2014-11-11 Thread Kishor Bhat
Hi Nikhil, 10 ^ 6 is the maximum number of digits, not the maximum number. In this solution, you're going to start from K and increment by one, checking at each stage whether ' n == rev(n)', which is a linear operation. Ultimately, this solution will be O(n ^ 2). A better approach might be to m

Re: [BangPypers] SPOJ : PALIN problem ...

2014-11-11 Thread Nikhileshkumar Ikhar
my bad. I'm wrong at many levels. Yes you are correct, for very large input it will be O(n^2). Regards, Nikhil On 11 November 2014 23:04, Kishor Bhat wrote: > Hi Nikhil, > > 10 ^ 6 is the maximum number of digits, not the maximum number. > > In this solution, you're going to start from K and i