Easy solution in c++ || using Sorting Algorithm
Intuition\nTo solve this problem, the initial thought is to prioritize smaller asteroids first, as they can be absorbed by the current mass, thereby increasing 
# Intuition\nTo solve this problem, the initial thought is to prioritize smaller asteroids first, as they can be absorbed by the current mass, thereby increasing the mass to handle larger asteroids later. By sorting the asteroids in ascending order, we can sequentially check if the current mass is sufficient to absorb each asteroid.\n\n# Approach\n1. **Sort the Asteroids:** First, sort the array of asteroid masses in ascending order. This allows us to handle the smallest asteroids first.\n\n2. **Iterate through Asteroids:** Start with the given mass and iterate through the sorted array of asteroids.\n\n3. **Check Absorption:** For each asteroid, check if the current mass is greater than or equal to the asteroid\u2019s mass:\n- If yes, absorb the asteroid by adding its mass to the current mass.\n- If no, it means the asteroid cannot be absorbed, and we should return false.\n\n4. **Return Result:** If all asteroids can be absorbed, return true.\n\n# Complexity\n- Time complexity:\n**O(nlogn)**\n\n- Space complexity:\n**O(1)**\n\n![3815c804-b225-4c1f-b62b-c2af5cfc1a0e_1679045089.4677224.jpeg](https://assets.leetcode.com/users/images/dedc9e77-3807-40cc-8399-a9bff962a63a_1719483069.1092482.jpeg)\n\n# Code\n```\nclass Solution {\npublic:\n    bool asteroidsDestroyed(int mass, vector<int>& nums) {\n\n        sort(nums.begin(), nums.end());\n        long long sum = mass;\n\n        for(int i = 0; i<nums.size(); i++)\n        {\n            if(sum >= nums[i])\n                sum += nums[i];\n            \n            else if(sum<nums[i])\n                sum -= nums[i];\n                \n        }\n        if(sum>=0)\n            return true;\n        return false;\n\n    }\n};\n```
['C++']