count_contained_permutations

package
v0.0.0-...-86b9fec Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: MIT Imports: 0 Imported by: 0

README

Count Contained Permutations

You're given two non-empty strings: a big string and a small string. Write a function that returns the number of permutations of the small string that are contained in the big string.

Repeated permutations should be counted, and the small string counts as a permutation of itself.

Sample Input

bigString = "cbabcacabca"
smallString = "abc"

Sample Output

6 // "cba", "abc", "bca", "cab", "abc", "bca"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountContainedPermutations

func CountContainedPermutations(bigString, smallString string) int

CountContainedPermutations O(b + s) time | O(s) space - where b is the length of the big input string and s is the length of the small input string

Types

type Trie

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

func NewTrie

func NewTrie() Trie

func (Trie) Add

func (t Trie) Add(str string, i int)

func (Trie) AddSlice

func (t Trie) AddSlice(slice []string)

Jump to

Keyboard shortcuts

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