1
kenpeter
160d

Did 2 leetcode today (technically 1)

https://leetcode.com/problems/...

idea:
* Palindrome means cut it half, rearrange the other half, will equal each other.
* Using javascript new map() to build a hash map
* Loop the hash, add up quotient*2, add up remainder.
* if remainder > 1, then return_sum+1

https://leetcode.com/problems/...
seen a few times in interview.

* do the big one first, i.e. if(n % (3*5) === 0)
* then n%3 === 0
* then n%5 === 0

Comments
  • 1
    I believe, using map in the first case is a bit of overkill. Array of 72 (or two arrays of 26 each) unsigned integers (for every Latin letter in upper and lower cases) would be simpler. 🤔
  • 0
Your Job Suck?
Get a Better Job
Add Comment