Just want to give a shout out to Daniel, who kept the interview lighthearted and fun :) I'm sure it goes a long way in easing the interviewee's anxiety and bringing out the best in them.
That was a really nice interview. Shout out to Daniel for keeping it friendly and lighthearted the whole time. I've been in interviews where the interviewer was very rigid and it in-turn made me very nervous.
It's funny this interview. At 10:25, the interviewer is actually wrong, you don't need quotes in JS. You can just do {a: 1, b: 2}. Python is the version where you'd need quotes. I'd probably comment on that and explain that in JS if you want to name something a key using a variable you would do {[a]: 1, [b]: 2}.
Thanks for the awesome interview! I was thinking, create trie out of words --> create freq map --> evaluate every word in the trie while using backtracking to undo modifications to the freq map. The efficiency here is that you don't recreate the freq map for each word + stopping early and not repeating work when evaluating words with same prefixes like 'dog' and 'dogs' etc.. run time: O(2D + T ---> D + T) D is number of letters in trie, T number of tiles in freq map
That's exactly right: preprocess. But not a TRIE for this problem. It doesn't actually help because you're not searching for a specific word, you're searching for words that can be MADE using the tiles.
Feel like the first answer was over engineered/hard to read. Here is what I came up with: const scoreWord = (word, tiles) => { let result = 0 for (const char of word) { if (tiles.includes(char)) { result += alphabet[char] tiles = tiles.replace(char, '') } else if (tiles.includes('_')) { tiles = tiles.replace('_', '') } else { return 0 } } return result } and for second question: const scoreWords = (words, tiles) => { let score = 0 let bestWord = '' for (const word of words) { let tempTiles = tiles let tempScore = 0 if (word.length > tiles.length) { return } for (const char of word) { if (tempTiles.includes(char)) { tempScore += alphabet[char] tempTiles = tempTiles.replace(char, '') } else if (tempTiles.includes('_')) { tempTiles = tempTiles.replace('_', '') } else { continue } if (tempScore > score) { score = tempScore bestWord = word } } } return [score, bestWord.length > 0 ? bestWord : null] } console.log(scoreWords(['cat', 'dog', 'foo'], 'cado_f')) //[5, "foo"]
Great interview and video! I felt like mentioning the optimization for the game of scrabble (wordbook wont change, can be fully processed) is kind of out of the scope of the problem at hand.
Hey Don, Would you be willing to do interviews with some people are aspiring developers? I think it would be beneficial to interview those who are working to becoming a developer. LOVE THE VIDEOS!
I'm definitely down to bring on aspiring developers for episodes. I believe I've created a post in the past inviting people, but no one followed through with it. Everyone wants to see episodes like that, but no one wants to volunteer.
Here's my solution to the second problem: def max_score(list_str, tiles): max = 0 word = "" for str in list_str: total = scorer(str, tiles) if total > max: max = total word = str return [max, word] print(max_score(["cat", "dog", "dogs", ], "tmac"))
The only thing that bothered me was that he was correct about copying the letters, all object keys are inherently strings and those keys were all valid var names in JavaScript. No quotes needed. Really cool interviewer, though. A+
Great practice interview and great job to Brian! Was a interesting problem, as I also never played Scrabble. Was also fun to try it myself and ended up getting a different solution. Thanks for sharing! const dictPoints = { a: 1, b: 3, c: 3, d: 2, e: 1, f: 4, g: 2, h: 4, i: 1, j: 8, k: 5, l: 1, m: 3, n: 1, o: 1, p: 3, q: 10, r: 1, s: 1, t: 1, u: 1, v: 4, w: 4, x: 8, y: 4, z: 10, _: 0, }; function getDictionary(object, key) { let result = object[key]; return result; } function checkMap(tiles) { let map = {}; for (let i = 0; i < tiles.length; i++) { if (!getDictionary(map, tiles[i])) { map[tiles[i]] = 1; } else { map[tiles[i]] += 1; } } return map; } function calculateWord2(array, tiles) { sum = 0; bestPoints = {}; map = checkMap(tiles); array.forEach((string) => { sum = 0; for (let i = 0; i < string.length; i++) { if (getDictionary(map, string[i])) { sum += getDictionary(dictPoints, string[i]); map[string[i]] -= getDictionary(map, string[i]) - 1; } bestPoints[string] = sum; } }); return bestPoints; }
Yep. Worst case time complexity remains the same but in real world cases this is an improvement. I do agree, it's kind of over engineering to address that in the first code through. Something to mentioning when asked, how to improve, IMO
It will return early in the iteration of words, if the largest possible word has been found, right? Constructing words takes some time, but querying the maximum value saves time. It's even better if, in a real project, you need to query different tiles @@garkman5000
Is it possible to get the word using the letters in the tiles, each letter can only be used once, underscore can represent any letter. Each letter has a value. Return the value of the word(each letter plus)
Live tech interviews make me cringe. I am forced to give them for interviews at my job and I hate them every time. Better options are to give the candidate a small project that might take a couple days or a weekend to complete. Also, can do it proctored to safeguard against any cheating (thanks to covid tons of services now exist). This would be a more real-life demo of their ability. Also, the dedication to complete it would scare off most, less dedicated people immediately. I know GitLab does something like this already.
Just want to give a shout out to Daniel, who kept the interview lighthearted and fun :) I'm sure it goes a long way in easing the interviewee's anxiety and bringing out the best in them.
Daniel is a goofy guy. I would have enjoyed being interviewed by him.
That was a really nice interview. Shout out to Daniel for keeping it friendly and lighthearted the whole time. I've been in interviews where the interviewer was very rigid and it in-turn made me very nervous.
This was actually a really good interview! Well done Brian!
I'm way too bad as a programmer but I managed to solve this with map, reduce. One of my proudest moments.
It's funny this interview. At 10:25, the interviewer is actually wrong, you don't need quotes in JS. You can just do {a: 1, b: 2}. Python is the version where you'd need quotes. I'd probably comment on that and explain that in JS if you want to name something a key using a variable you would do {[a]: 1, [b]: 2}.
He was probably thinking of JSON, which has mandatory quotes
I was thinking this very same thing
Thanks for the awesome interview!
I was thinking, create trie out of words --> create freq map --> evaluate every word in the trie while using backtracking to undo modifications to the freq map.
The efficiency here is that you don't recreate the freq map for each word + stopping early and not repeating work when evaluating words with same prefixes like 'dog' and 'dogs' etc..
run time: O(2D + T ---> D + T) D is number of letters in trie, T number of tiles in freq map
That's exactly right: preprocess. But not a TRIE for this problem. It doesn't actually help because you're not searching for a specific word, you're searching for words that can be MADE using the tiles.
Daniel was awesome. It's better to have lighthearted goofy interviewer than stone faced interviewer who says nothing, I hate those interviews.
Lets goo Brian!!!
Let’s go Brain!! 🙌
Feel like the first answer was over engineered/hard to read. Here is what I came up with:
const scoreWord = (word, tiles) => {
let result = 0
for (const char of word) {
if (tiles.includes(char)) {
result += alphabet[char]
tiles = tiles.replace(char, '')
} else if (tiles.includes('_')) {
tiles = tiles.replace('_', '')
} else {
return 0
}
}
return result
}
and for second question:
const scoreWords = (words, tiles) => {
let score = 0
let bestWord = ''
for (const word of words) {
let tempTiles = tiles
let tempScore = 0
if (word.length > tiles.length) {
return
}
for (const char of word) {
if (tempTiles.includes(char)) {
tempScore += alphabet[char]
tempTiles = tempTiles.replace(char, '')
} else if (tempTiles.includes('_')) {
tempTiles = tempTiles.replace('_', '')
} else {
continue
}
if (tempScore > score) {
score = tempScore
bestWord = word
}
}
}
return [score, bestWord.length > 0 ? bestWord : null]
}
console.log(scoreWords(['cat', 'dog', 'foo'], 'cado_f')) //[5, "foo"]
Great interview and video!
I felt like mentioning the optimization for the game of scrabble (wordbook wont change, can be fully processed) is kind of out of the scope of the problem at hand.
Nice job Brian!
Wow what an amazing interview, thank you so much for your content.
Hey Don,
Would you be willing to do interviews with some people are aspiring developers? I think it would be beneficial to interview those who are working to becoming a developer.
LOVE THE VIDEOS!
I'm definitely down to bring on aspiring developers for episodes. I believe I've created a post in the past inviting people, but no one followed through with it. Everyone wants to see episodes like that, but no one wants to volunteer.
@@DonTheDeveloper
I’m open to joining the conversation. My background is a little different which could make a discussion interesting.
@@mrawesome1821 Sounds good. Go ahead and email me if you're interested in coming onto the podcast. You can find my email address on the About page.
Here's my solution to the second problem:
def max_score(list_str, tiles):
max = 0
word = ""
for str in list_str:
total = scorer(str, tiles)
if total > max:
max = total
word = str
return [max, word]
print(max_score(["cat", "dog", "dogs", ], "tmac"))
yeah but your time complexity sucks
It's impossible to read the question. Can someone please post it here?
The only thing that bothered me was that he was correct about copying the letters, all object keys are inherently strings and those keys were all valid var names in JavaScript. No quotes needed.
Really cool interviewer, though. A+
Zooming in would have been nice
Great practice interview and great job to Brian! Was a interesting problem, as I also never played Scrabble. Was also fun to try it myself and ended up getting a different solution.
Thanks for sharing!
const dictPoints = {
a: 1,
b: 3,
c: 3,
d: 2,
e: 1,
f: 4,
g: 2,
h: 4,
i: 1,
j: 8,
k: 5,
l: 1,
m: 3,
n: 1,
o: 1,
p: 3,
q: 10,
r: 1,
s: 1,
t: 1,
u: 1,
v: 4,
w: 4,
x: 8,
y: 4,
z: 10,
_: 0,
};
function getDictionary(object, key) {
let result = object[key];
return result;
}
function checkMap(tiles) {
let map = {};
for (let i = 0; i < tiles.length; i++) {
if (!getDictionary(map, tiles[i])) {
map[tiles[i]] = 1;
} else {
map[tiles[i]] += 1;
}
}
return map;
}
function calculateWord2(array, tiles) {
sum = 0;
bestPoints = {};
map = checkMap(tiles);
array.forEach((string) => {
sum = 0;
for (let i = 0; i < string.length; i++) {
if (getDictionary(map, string[i])) {
sum += getDictionary(dictPoints, string[i]);
map[string[i]] -= getDictionary(map, string[i]) - 1;
}
bestPoints[string] = sum;
}
});
return bestPoints;
}
console.log(calculateWord2(["cat", "dog", "test"], "tke_skdac"));
Very good interview ingles!
Is helping the interview...
Isn't the time complexity of Q2 the same as checking the score for every word? He's just pruning the search but not improving the time complexity.
Yep. Worst case time complexity remains the same but in real world cases this is an improvement. I do agree, it's kind of over engineering to address that in the first code through. Something to mentioning when asked, how to improve, IMO
It will return early in the iteration of words, if the largest possible word has been found, right? Constructing words takes some time, but querying the maximum value saves time. It's even better if, in a real project, you need to query different tiles @@garkman5000
And leetcode reference of the second problem?
Well i would like to try (:
I didn't understood the first question only can anyone explain it to me
Is it possible to get the word using the letters in the tiles, each letter can only be used once, underscore can represent any letter. Each letter has a value. Return the value of the word(each letter plus)
Actually using a Trie tree in this problem would increase the complexity so much. I like the map approach.
Nice job
SamWell in GOT?
I was nothing at all, and when you're nothing at all, there's no more reason to be afraid.
I am supposed to have an interview in a couple of weeks, after seeing this I should just cancel it and save myself and my interviewer time.
Live tech interviews make me cringe. I am forced to give them for interviews at my job and I hate them every time. Better options are to give the candidate a small project that might take a couple days or a weekend to complete. Also, can do it proctored to safeguard against any cheating (thanks to covid tons of services now exist). This would be a more real-life demo of their ability. Also, the dedication to complete it would scare off most, less dedicated people immediately. I know GitLab does something like this already.
FIRST