Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Assuming the input string and pattern is in lowercase alphabets, here is the gol...

Bipra

Feb 14, 2022

Assuming the input string and pattern is in lowercase alphabets, here is the golfing solution

var result []int patternFrequency := [26]int{} charFrequency := [26]int{} for _, c := range pattern { patternFrequency[c-97] += 1 } for i := 0; i < len(pattern); i++ { charFrequency[input[i]-97]++ } if charFrequency == patternFrequency { result = append(result, 0) } for i := 1; i

0

0

Comments
Comments

On this page