twopointers

package
v0.0.0-...-d6c755d Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxInt  = 1<<(UintSize-1) - 1 // 1<<31 - 1 or 1<<63 - 1
	MinInt  = -MaxInt - 1         // -1 << 31 or -1 << 63
	MaxUint = 1<<UintSize - 1     // 1<<32 - 1 or 1<<64 - 1
)
View Source
const UintSize = 32 << (^uint(0) >> 32 & 1) // 32 or 64

Variables

This section is empty.

Functions

func IsPalindrome

func IsPalindrome(s string) bool

IsPalindrome returns True if given string is a palindrome uses a two pointers which start from both ends of the string comparing and moving towards the middle of the string O(n) time, O(1) space

func MaxProfit

func MaxProfit(prices []int) int

maxProfit returns the maximum profit given the prices

func MinimumWindowSort

func MinimumWindowSort(s []int) []int

mimimumwindowsort find minumum window when sorted will sort the whole slice two pointers approach O(n) time and O(1) space

func TwoNumberTargetSum

func TwoNumberTargetSum(nums []int, target int) bool

two_numbers_target_sum given slice and target return true if 2 numbers sum up to the target O(n) time and O(n) space

Types

This section is empty.

Jump to

Keyboard shortcuts

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