day195

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: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountLargerAndSmallerBrute

func CountLargerAndSmallerBrute(mat Matrix, i1, j1, i2, j2 int) int

CountLargerAndSmallerBrute computes the number of elements of M smaller than M[i1, j1] and larger than M[i2, j2]. Runs in O(M*N) time. Scans the entire matrix.

func CountLargerAndSmallerEfficient

func CountLargerAndSmallerEfficient(mat Matrix, i1, j1, i2, j2 int) int

CountLargerAndSmallerEfficient computes the number of elements of M smaller than M[i1, j1] and larger than M[i2, j2]. Runs in O(Answer). Only examines the number of elements in the answer.

Types

type Matrix

type Matrix [][]int

Matrix is a M by N matrix of integers.

Jump to

Keyboard shortcuts

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