This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func canConstruct(ransomNote string, magazine string) bool { | |
for _, v := range ransomNote { | |
sym := string(v) | |
ind, exists := searchInString(magazine, sym) | |
if !exists { | |
return false | |
} | |
magazine = magazine[:ind] + magazine[ind+1:] | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func search(nums []int, target int) int { | |
low := 0 | |
high := len(nums)-1 | |
for low <= high { | |
mid := low + (high - low)/2 | |
guess := nums[mid] | |
if guess == target { | |
return mid | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"io" | |
"io/ioutil" | |
"github.com/h2non/filetype" | |
) |