1920. Build Array from Permutation 發表於 2023-02-13 | 分類於 leetcode problemsolutionoption 11234567891011class Solution {public: vector<int> buildArray(vector<int>& nums) { int n= nums.size(); vector<int> ret; for(int i=0;i<n;++i){ ret.push_back(nums[nums[i]]); } return ret; }}; option 2 - follow up O(1) spaceanalysis time complexity O(n) space complexity O(n)