Hash Tables: Ransom Note

  • + 0 comments

    Go solution pretty simple

    	dic := make(map[string]int)
    	for _, n := range magazine {
    		dic[n]++
    	}
    	for _, n := range note {
    		if val, ok := dic[n]; !ok || val == 0 {
    			fmt.Println("No")
    			return
    		} else {
    			dic[n]--
    		}
    	}
    	fmt.Println("Yes")
    }