Algorithm(2)
-
20200630 programmers print
def max_count(priorities): max_num = 0 max_idx = 0 length = len(priorities) for i in range(length): if priorities[i] > max_num: max_num = priorities[i] max_idx = i return max_num, max_idx def solution(priorities, location): answer = 0 while True: max_num, max_idx = max_count(priorities) if location > max_idx: priorities = priorities[max_idx+1:] + priorities[:max_idx] location = location - max_id..
2020.06.30 -
20200625 Leetcode two sum python solution
class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: hmap = {} for i in range(len(nums)): idx = hmap.get(nums[i]) if idx: return [idx-1,i] hmap[target-nums[i]] = i+1
2020.06.25