diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/sort_array_parity.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/sort_array_parity.cpp')
-rw-r--r-- | other/sort_array_parity.cpp | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/other/sort_array_parity.cpp b/other/sort_array_parity.cpp deleted file mode 100644 index 33f02b1..0000000 --- a/other/sort_array_parity.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - vector<int> sortArrayByParity(vector<int> &nums) { - /* - * important to assign vector values first: - * vector... var(size, vals) - */ - vector<int> ans(nums.size(), 0); - - /* - * start at first element (0) - * end at "last" element minus 1 - * because arrays initialize at 0 - */ - int start = 0, end = nums.size() - 1; - - for (int i = 0; i < nums.size(); i++) { - if (nums[i] % 2 == 1) - /* - * odd - * assign "last" array value to current nums value - * and incrementally decrease end when necessary - */ - ans[end--] = nums[i]; - else - /* - * even - * assign "first" array value to current nums value - * and incrementally increase start when necessary - */ - ans[start++] = nums[i]; - } - return ans; - } -}; - -int main() { - vector<int> nums = {3, 1, 2, 4}; - Solution obj; - for (int i = 0; i < nums.size(); i++) - cout << nums[i] << ' '; - cout << endl; - obj.sortArrayByParity(nums); -} |