Skip to content

Instantly share code, notes, and snippets.

@ConnorAndersonLarson
Created June 8, 2021 15:39
Show Gist options
  • Save ConnorAndersonLarson/a6aba945e4266ec00efea9f20dabdd63 to your computer and use it in GitHub Desktop.
Save ConnorAndersonLarson/a6aba945e4266ec00efea9f20dabdd63 to your computer and use it in GitHub Desktop.
Palindrome Tech Challenge

Problem - Next Palindrome

Any number that reads the same way forwards as it does backwards is a palindrome. For instance, 12321 would be considered a palindrome, whereas 123 would not be.

Write a function that takes in an integer and returns the next palindrome. For instance:

findNextPalindrome(100)
// should return 101

and

findNextPalindrome(101)
// should return 111

Instructions

  1. Copy this markdown and paste in your own, private gist
  2. In your private gist, fill out the questions below
  3. Submit by the due time as instructed in Zoom

Rewrite the question in your own words:

Given a starting number, return the closest palindrome to the starting number.

What assumptions will you make about this problem if you cannot ask any more clarifying questions? What are your reasons for making those assumptions?

I will be given a number I will be counting upwards only There will be no number to count up to

What are your initial thoughts about this problem? (high level design, 2-3 sentences)

This problem will require a standard for loop with a return. It will also need a function to check for the palindrome within the number.

How would you identify the elements of this problem?

  • Searching of Data
  • Sorting of Data
  • Pattern Recognition
  • Build/Navigate a Grid
  • Math
  • Language API knowledge
  • Optimization

Which data structure(s) do you think you'll use? What pros/cons do you see with that choice?

array as they are easy to iterate through and convert data types into.

Write out a few lines of initial pseudocode: (mid-level design, NOT REAL CODE)

assign a parameter for the number to start from utilize a for loop to iterate through starting from parameter number in the loop add a check for palindrome if the check returns true, return number

Write out any implementation code OR link to repl

https://replit.com/@ConnorAndersonL/DiligentUnnaturalBusiness#index.js

What is the Big O complexity of your solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment