BackmediumArrays PhonePe

NEW OR EXISTING ID 4 Solution

Problem Statement

Given an array of integers, return the array with all occurrences of 4 removed if it exists.

Example 1
Input
[1, 2, 3, 4]
Output
[1, 2, 3]

Explanation: Step-by-step: Given the input array [1, 2, 3, 4], we first check if the array contains the value 4. Since it does, we remove the value 4 from the array. The resulting array is [1, 2, 3].

Example 2
Input
[1, 2, 3, 4, 4, 4]
Output
[1, 2, 3]

Explanation: Step-by-step: Given the input array [1, 2, 3, 4, 4, 4], we first check if the array contains the value 4. Since it does, we remove all occurrences of the value 4 from the array. The resulting array is [1, 2, 3].

Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free