stripzero

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2026 License: BSD-3-Clause Imports: 0 Imported by: 0

README

NAME

9 - in place zero out the row and column of a zero cell in a matrix

DESCRIPTION

Problem

Given a matrix m-by-n, zero out entire row and column of every cell that has zero in place.

Example

Consider the following input matrix:

1 1 1 1
1 0 1 1
1 1 1 1
1 1 1 0

Output:

1 0 1 0
0 0 0 0
1 0 1 0
0 0 0 0

SEE ALSO

Documentation

Overview

Example
package main

import (
	"fmt"

	"github.com/skhal/lab/iq/9/stripzero"
)

func main() {
	matrix := [][]int{
		[]int{1, 1, 1, 1},
		[]int{1, 0, 1, 1},
		[]int{1, 1, 1, 1},
		[]int{1, 1, 1, 0},
	}
	stripzero.Clean(matrix)
	for _, nn := range matrix {
		fmt.Println(nn)
	}
}
Output:
[1 0 1 0]
[0 0 0 0]
[1 0 1 0]
[0 0 0 0]

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean(m [][]int)

func CleanOptimal

func CleanOptimal(m [][]int)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL