python-algorithm1422 Leetcode 9. Palindrome Number 1 2 3 4 5 class Solution: def isPalindrome(self, x: int) -> bool: x=str(x) if x== x[::-1] : return True else : return False cs 팰린드롬 숫자 백준에도 많이 있는 유형이에요 쉽습니다 2021. 7. 12. Leetcode 7. Reverse Integer 1 2 3 4 5 6 7 8 9 10 class Solution: def reverse(self, x: int) -> int: x=str(x) if x[0]=='-': x=int(x[::-1][:-1])*-1 if x=pow(2,31)-1 : x=0 return x cs 문제 자체는 안어려운데요 예외조건 Given~ 부분 잘 읽어보셔야됩니더 2021. 7. 12. Leetcode 1. Two Sum 1 2 3 4 5 6 7 8 9 10 class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: for i in range(len(nums)): for j in range(i+1,len(nums)): if target== nums[i]+nums[j]: tmp=[] tmp.append(i) tmp.append(j) return tmp break Colored by Color Scripter cs 2021. 7. 12. Leetcode 1672. Richest Customer Wealth 1 2 3 4 5 6 7 class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: tmp=[] for i in range(len(accounts)): tmp.append( sum(accounts[i])) return max(tmp) Colored by Color Scripter cs 2021. 7. 12. Leetcode 1108. Defanging an IP Address 1234class Solution: def defangIPaddr(self, address: str) -> str: address=address.replace('.','[.]') return addresscs 2021. 7. 12. Leetcode 1480. Running Sum of 1d Array 1 2 3 4 5 6 class Solution: def runningSum(self, nums: List[int]) -> List[int]: tmp=[] for i in range(len(nums)): tmp.append(sum(nums[:i+1])) return tmp Colored by Color Scripter cs 2021. 7. 12. Leetcode 1920 1 2 3 4 5 6 class Solution: def buildArray(self, nums: List[int]) -> List[int]: tmp=[] for i in nums: tmp.append(nums[i]) return tmp Colored by Color Scripter cs 2021. 7. 12. Leetcode 1929 1 2 3 4 5 6 7 class Solution: def getConcatenation(self, nums: List[int]) -> List[int]: tmp=[] for i in range(2): for j in nums: tmp.append(j) return tmp Colored by Color Scripter cs 2021. 7. 12. 백준 21300 1 2 tmp=list(map(int, input().split())) print(sum(tmp)*5) cs 2021. 5. 3. 백준 8437 1 2 3 4 a=int(input()) b=int(input()) print( (a-b)//2+b) print( (a-b)//2) cs 2021. 5. 3. [백준] 10480 1 2 3 4 for i in range(int(input())): n=int(input()) if n%2==0: print("%d is even"%n) else: print("%d is odd"%n) cs 2021. 3. 19. [백준] 10262 1 2 3 4 5 6 7 tmp1=list(map(int,input().split())) tmp2=list(map(int,input().split())) a=sum(tmp1) b=sum(tmp2) if a>b : print("Gunnar") elif a==b: print("Tie") else: print("Emma") cs 2021. 3. 19. 이전 1 ··· 71 72 73 74 75 76 77 ··· 119 다음