IT/코딩테스트 (111) 썸네일형 리스트형 [Leetcode] 27. Remove Element https://leetcode.com/problems/remove-element/ class Solution: def removeElement(self, nums: List[int], val: int) -> int: nums_count = len(nums) val_count = nums.count(val) for i in range(val_count): nums.remove(val) nums.append(val+1) return nums_count - val_count [Leetcode] 383. Ransom Note https://leetcode.com/problems/ransom-note/ class Solution: def canConstruct(self, ransomNote: str, magazine: str) -> bool: maga = list(magazine) for l in ransomNote: if not l in maga: return False else: maga.remove(l) return True [Leetcode] 511. Game Play Analysis I https://leetcode.com/problems/game-play-analysis-i/ # Write your MySQL query statement below select player_id, min(event_date) as first_login from Activity group by player_id; [Leetcode] 1342. Number of Steps to Reduce a Number to Zero https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/ class Solution: def numberOfSteps(self, num: int) -> int: count = 0 while num != 0: if num % 2 == 0: num //= 2 else: num -= 1 count += 1 return count [Leetcode] 412. Fizz Buzz https://leetcode.com/problems/fizz-buzz/ class Solution: def fizzBuzz(self, n: int) -> List[str]: result = [] for i in range(1, n+1): if ((i % 3 == 0) and (i % 5 == 0)): result.append('FizzBuzz') elif (i % 3 == 0): result.append('Fizz') elif (i % 5 == 0): result.append('Buzz') else: result.append(str(i)) return result [Leetcode] 1672. Richest Customer Wealth https://leetcode.com/problems/richest-customer-wealth/ int maximumWealth(int** accounts, int accountsSize, int* accountsColSize){ int max = 0; for (int i = 0; i max) { max = sum; } } return max; } [Leetcode] 1480. Running Sum of 1d Array https://leetcode.com/problems/running-sum-of-1d-array/ /** * Note: The returned array must be malloced, assume caller calls free(). */ int* runningSum(int* nums, int numsSize, int* returnSize){ int* result = (int *)malloc(sizeof(int) * numsSize); memset(result, 0, sizeof(int) * numsSize); *returnSize = numsSize; for (int i=0; i < numsSize; i++) { for (int j=0; j 이전 1 ··· 11 12 13 14 다음