day456

package
v0.0.0-...-36687a4 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BusiestBuildingTimes

func BusiestBuildingTimes(moves []Movement) (uint64, uint64)

BusiestBuildingTimes returns the timestamp start and end when the building has the most people. Runs in O(N log N) time because it sorts the input by timestamp. Assumes building starts with 0 people and ends with 0 people.

Types

type EnterOrExit

type EnterOrExit string

EnterOrExit represents either entering the building or exiting.

const (
	// Enter means people are entering the building.
	Enter EnterOrExit = "enter"
	// Exit means people are leaving the building.
	Exit EnterOrExit = "exit"
)

type Movement

type Movement struct {
	Timestamp uint64
	Count     int
	Type      EnterOrExit
}

Movement is an entry in the building's movement slice.

Jump to

Keyboard shortcuts

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