Skip to content

Instantly share code, notes, and snippets.

import kotlin.random.Random
class RandomWordGenerator(words: List<String>) {
private val graph = mutableMapOf<Char, MutableSet<Char>>()
private val firstLetters = mutableSetOf<Char>()
private val lastLetters = mutableSetOf<Char>()
init {
words.forEach { word ->
word.forEachIndexed { index, currentLetter ->
@kchromik
kchromik / Coding Interview Video
Created April 28, 2023 11:05
Coding Interview Video
import Foundation
class RandomWordGenerator {
private var graph: [Character: Set<Character>] = [:]
private var firstLetters: Set<Character> = []
private var lastLetters: Set<Character> = []
func insert(words: [String]) {
words.forEach { word in
guard !word.isEmpty else { return }