• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Add a number which in form of String

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For a competitive programming problem I need to get a number which has 100000 digit as input and find next palindrome , I have coded half of the logic, for another half I need to add one(1) to the half portion of 500 digit string . I used some logic and it did not work out , if I use biginteger "TLE" error occurs. So please let me know a logic. To add just one to a String and get the result.
 
author & internet detective
Posts: 41250
849
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

krishna kumar.s wrote:For a competitive programming problem


This implies you should be writing the code yourself. What do you have so far with BigInteger? If you are allowed to show code, show a self contained example that illustrates the error.

There's probably some shortcuts to brute force since this is a competition. Maybe looking for patterns so you don't have to keep adding 1 at a time.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

krishna kumar.s wrote:I used some logic and it did not work out , if I use biginteger "TLE" error occurs. So please let me know a logic...


I'm afraid that's not how it works here. Why don't you show us what you've tried and precisely what errors you're getting (I have no idea what a 'TLE' error is) - cut and paste the stacktrace if you need to.

My suspicion is that you might not need BigInteger though, since the entire process (including "incrementing") can probably be done with the String - or maybe even better, a char[].
Hint: chars in Java are numeric.

Interesting little problem though.

Winston
 
Marshal
Posts: 76403
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's TLE?
 
We find this kind of rampant individuality very disturbing. But not this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic