arrays

package
v0.0.0-...-03d60e9 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(v int) int

There are three types of edits that can be performed on strings: Insert a character, remove a character, or replace a character. Given two strings, write a function to check if they are one edit (or zero edits) away.

for exmaple:

  • pale, ple √ 1 char removed
  • pales, pale √ 1 char removed
  • pale, bale √ 1 char replaced
  • pale, bake X 2 chars replaced
  • pae, pale √ 1 char removed

This has an O(n) runtime

func ArePermutations

func ArePermutations(s1 string, s2 string) bool

func ArrayToString

func ArrayToString(array []int) string

func MergeSort

func MergeSort(array *[]int, indent int)

func QuickSort

func QuickSort[T cmp.Ordered](arr []T, low int, high int)

Types

type Pixel

type Pixel struct {
	// contains filtered or unexported fields
}

Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?

I like to show this in a picture so that I can spot the pattern.

For example:

This can represent the 2x2 image array. [

[ a, b ],
[ c, d ]

]

What we want is: [

[ c, a ],
[ d, b ]

]

The coordinates change from, to:

00 -> 01 01 -> 11 11 -> 10 10 -> 00

Jump to

Keyboard shortcuts

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