리드코드 4

LeetCode - 1920. Build Array from Permutation

Problem Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 List[int]: ans = [] for i in range(len(nums)): ans.append(nums[nums[i]]) return ans 내 생애 처음 풀어 본 리드코드 문제 결국은 해결책을 보고 이해를 했다. ans = []는 배열을 지정했다. for in range는 반복문이고, len(nums)는 어떻게 반복 할 것인가에 대한 조건이다. len은 길이다. Example 1에 보면 숫자가 6개가 있다. 그렇다 이 for in range는 6번 반복 될..

초보코딩 2021.08.04