A chat app keeps the ids of everyone in a room in userIds. When someone is muted, every copy of their id must be removed before the list is rendered.
Write dropMuted(userIds, muted) that removes every item equal to muted from userIds in place, keeping the other ids in their original order, and shortens the array so it holds only the kept ids. Don't create a second array. The tests check userIds after your function runs.
Input: userIds = [4,7,2,7,9], muted = 7 Output: [4,2,9]
Both copies of 7 are removed; 4, 2, 9 keep their order.
Input: userIds = [1,2,3], muted = 5 Output: [1,2,3]
Nobody in the room is muted.
0 <= userIds.length <= 1000000 <= userIds[i], muted <= 10^6Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #106 Drop Muted Users. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.