Cody

Problem 2351. Replace Nonzero Numbers with 1

Given the matrix x, return the matrix y with non zero elements replaced with 1.

Example:

 Input  x =  [ 1 2 0 0 0
               0 0 5 0 0 
               2 7 0 0 0
               0 6 9 3 3 ]
 Output y is [ 1 1 0 0 0
               0 0 1 0 0 
               1 1 0 0 0
               0 1 1 1 1 ]

Solution Stats

31.28% Correct | 68.72% Incorrect
Last solution submitted on Oct 20, 2019

Problem Comments


Problem Recent Solvers100

Problem Tags