1. Problem Statement (Simple Explanation): You are given: An integer array nums An integer val You must: Remove all occurrences of val from nums in-place . The order of remaining elements may change (no need to keep original order). Return k = the number of elements in nums that are not equal to val. After your function: The first k elements of nums must be the elements that are not equal to val (order doesn’t matter). The rest of the elements beyond index k - 1 can be anything. 2. Examples: Example 1: Input: nums = [3,2,2,3], val = 3 All 3s are removed, remaining elements are [2,2]. Output: k = 2, nums = [2,2,_,_] Example 2: Input: nums = [0,1,2,2,3,0,4,2], val = 2 Elements not equal to 2 are: 0,1,3,0,4 (any order allowed). Output: k = 5, nums = [0,1,4,0,3,_,_,_] Constraints: 0 <= nums.length ...
1. Problem Statement (Simple Explanation): You are given an integer array nums that is sorted in non-decreasing order. You must: Remove duplicates in-place so that each unique element appears only once . Keep the relative order of unique elements. Return k, the number of unique elements . After your function: The first k elements of nums should contain the unique elements in sorted order. Anything beyond index k - 1 can be ignored. You must use only constant extra space O(1). 2. Examples: Example 1: Input: nums = [1,1,2] Unique elements are [1,2]. Output: k = 2, nums = [1,2,_] (Underscore means “don’t care” beyond k.) Example 2: Input: nums = [0,0,1,1,1,2,2,3,3,4] Unique elements: [0,1,2,3,4]. Output: k = 5, nums = [0,1,2,3,4,_,_,_,_,_] Constraints: 1 <= nums.length <= 3 x 10 4 -100 <= nums[i] <= 100 nums is sorted in non-decreasing or...