[JavaScript] 2216. Minimum Deletions to Make Array Beautiful
---\n\n- Implementation, after we write, is easy\n\n---\n\nWeekly Contest 286\n- Q1 answer - https://leetcode.com/problems/find-the-difference-of-two-arrays/dis
---\n\n- Implementation, after we write, is easy\n\n---\n\n**Weekly Contest 286**\n- **Q1** answer - https://leetcode.com/problems/find-the-difference-of-two-arrays/discuss/1889224/JavaScript-2215.-Find-the-Difference-of-Two-Arrays\n- **Q2** answer - https://leetcode.com/problems/minimum-deletions-to-make-array-beautiful/discuss/1890258/JavaScript-2216.-Minimum-Deletions-to-Make-Array-Beautiful\n  - **below**\n- **Q3** answer - https://leetcode.com/problems/find-palindrome-with-fixed-length/discuss/1892167/JavaScript-2217.-Find-Palindrome-With-Fixed-Length\n\n---\n\nHope it is simple to understand.\n\n---\n\n```\nvar minDeletion = function (nums) {\n    const n = nums.length;\n\n    let deletes = 0;\n    for (let i = 0; i < n - 1; i++) {\n        let j = i - deletes; // new i\n        if (\n            j % 2 === 0 && //\n            nums[i] === nums[i + 1]\n        ) {\n            deletes++;\n        }\n    }\n\n    // nums.length must be is even, if odd delete 1 more\n    return deletes + ((n - deletes) % 2);\n};\n```\n\n---\n
['JavaScript']