Input: nums = [2,7,11,15], target = 9Output: [0,1]Output: Because nums[0] + nums[1] == 9, we return [0, 1].
題目如上:給定一個List 跟一個Target,例如上例nums=[2,7,11,15] target = 9,因為第0號位置加第1號位置也就是2+7會等於9,因此返回位置值[0,1]。
Input: x = 123Output: 321Input: x = -123Output: -321
題目: 有個整數,把它倒敘,有給定範圍-2^31 < x < 2^31 - 1
-2^31 < x < 2^31 - 1
Coding:
class Solution: def reverse(self, x: int) -> int: num=0 a=abs(x) while…