[LeetCode]#2119. A Number After a Double Reversal

  • For example, reversing 2021 gives 1202. Reversing 12300 gives 321 as the leading zeros are not retained.
Input: num = 526
Output: true
Explanation: Reverse num to get 625, then reverse 625 to get 526, which equals num.
  1. Convert input to string format and reverse it
  2. Convert it to int format.
  3. Convert it to a string format and reverse it.
  4. If input equal converted result, return pass.
  5. Else, return Fail.
class Solution:
def isSameAfterReversals(self, num):
if int(temp) ==num:
return True
return False

Interesting in any computer science.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Effective Code Reviews for the whole team

Spark Convert case class to Schema — Spark by {Examples}

Enable Single Sign-On Using SAML On AssetSonar

A History of Creative Coding

GUI Application on Docker Container

Inheritance and Composition

Comparison between Inheritance and Composition

Deep dive into HTTP

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Fatboy Slim

Fatboy Slim

Interesting in any computer science.

More from Medium

[LeetCode]#2032. Two Out of Three

LeetCode Patterns Adventure 12 — Palindrome Linked List

Python TreeMap

4-in-1 Priority First Search in Python: BFS, DFS, Prim’s, and Dijkstra’s algorithms