✅ [C++] EASY and Shorter Solution || Standard LIS Variation || INTUITIVE approach
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\nO(N*N)\nReason: There are two nested loops.\n\n- Space complexity:\nSpace Complexity: O(N)\nReason: We are only using two rows of size n.\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> largestDivisibleSubset(vector<int>& nums) {\n        \n        int n = nums.size() ,ans = -1 ,  lastIndex =-1;\n        vector<int> dp(n, 1);\n        vector<int> trace(n, -1);\n        sort(nums.begin() , nums.end());\n\n     for(int i = 0; i < n; i++){\n          for(int j = 0; j < i; j++){\n\n             if((nums[i]%nums[j] == 0) && dp[j] >= dp[i]){ dp[i] = dp[j] + 1;   trace[i] = j;}             \n         }\n           if(dp[i] > ans){ans = dp[i];  lastIndex = i;} \n    }\n\n        vector<int>path;\n        while(lastIndex != -1){\n            path.push_back(nums[lastIndex]);\n            lastIndex = trace[lastIndex];\n        }\n        reverse(path.begin(), path.end());       \n          return path;\n    }\n    \n};\n```
['C++']