Replace Negatives Problem

Replace Negatives Problem — ExecCode School DSA Practice

Solve the Replace Negatives problem on ExecCode. Free online school DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

You are given a list of whole numbers. Your task is to go through each number in the list. If a number is a negative number (less than zero), change it to zero. If the number is zero or a positive number, leave it as it is. Print the list of numbers after you have made all the changes.

Examples

Input 5 1 2 3 4 5; Output 1 2 3 4 5. Input 5 -1 -2 -3 -4 -5; Output 0 0 0 0 0

Constraints

1 <= N <= 1000 -10^5 <= Array Elements <= 10^5

Practice Replace Negatives free on ExecCode. Browse DSA problems, topic map, and placement guides.