Leetcode Flashcards

1
A
class Solution:
    def converter(self, n: int, x: int):
        res = ""
        while n:
            res += str(n%x)
            n //= x
        return res[::-1]

    def isStrictlyPalindromic(self, n: int) -> bool:
        return all(self.converter(n,i) == self.converter(n,i)[::-1] for i in range(2,n-1))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
A
class Solution:
    def xorOperation(self, n: int, start: int) -> int:
        result = 0
        for i in range(n):
            tmp = start + 2*i 
            result = result ^ tmp 
        return result
How well did you know this?
1
Not at all
2
3
4
5
Perfectly