shiftzeros

package
v0.0.0-...-75ded5f Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: BSD-3-Clause Imports: 1 Imported by: 0

README

NAME

shiftzeros - shift zeros to the end of a collection

PROBLEM

Given an array of numbers, perform in place move of zeros to the end of the array. Maintain the relative order of non-zero elements.

EXAMPLE

Input: [0, 1, 0, 3, 2]

Output: [1, 3, 2, 0, 0]

SEE ALSO

Solution

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Shift

func Shift(nn []int)
Example
package main

import (
	"fmt"

	"github.com/skhal/lab/iq/5/shiftzeros"
)

func main() {
	nn := []int{0, 1, 0, 3, 2}
	shiftzeros.Shift(nn)
	fmt.Printf("%v\n", nn)
}
Output:

[1 3 2 0 0]

Types

This section is empty.

Jump to

Keyboard shortcuts

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