student student Interview Question for Students Students






Comment hidden because of low score. Click to expand.
1
of 1 vote

if 3rd digit is greater than 4th digit, then largest palindrome smaller than X would be "1st digit, 2nd digit, 3rd digit -1, 3rd digit -1, 2nd digit, 1st digit" and smallest palindrom larger than X would be "1st digit, 2nd digit, 3rd digit, 3rd digit, 2nd digit, 1st digit".
And if 3rd digit is smaller or equal to 4th digit, then in above solution... smallest one will become largest one and vice versa.

- Anonymous October 31, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

just decrease the X value and check it every number is palindrome or not, then will get largest palindrome smaller than X.
same way increase the X value and check it, then you will get smaller palindrome value greater than X.

- pmahesh.417 February 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

given X = 888888, your algorithm would indicate 888888 as "the smallest palindrome larger than X", but clearly 888888is not larger than 888888.

- Anonymous November 04, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

if both are equal increment the 3rd digit by 1 :)

- artemis November 04, 2012 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More