Count and Say | LeetCode 38 | Coding Interview Tutorial

preview_player
Показать описание
Count and Say solution: LeetCode 38

AFFILIATE LINKS
If you're interested in learning algorithms, these are great resources.

💲 All coupons and discounts 💲

Count and Say | LeetCode 38 | Coding Interview
#countandsay #leetcode #algorithms #terriblewhiteboard #codinginterview

Click the time stamp to jump to different parts of the video.
00:00 Title
00:07 Problem readout
01:17 Whiteboard solution
05:18 Coding solution
18:09 Result and outro
Рекомендации по теме
Комментарии
Автор

If there are any videos you'd like me to make or if you have any ideas on how to optimize this solution, let me know!

TerribleWhiteboard
Автор

Thanks for the explanation. I had never got the point of this problem, until I saw this video. You can see it from the problem description. This task has ~200 likes and ~7000 dislikes on Leetcode.

hennadiikasian
Автор

Best of the best explanation. I think understanding the problem here is the biggest challenge than actually solving it.

Row 1: "1" (Base case)
Row 2: "11" (Previous has one 1s)
Row 3: "21" (Previous has two 1s)
Row 4: "1211" (Previous has one 2s and one 1s)
Row 5: "111221" (Previous has one 1s and one 2s and two 1s)
Row 6: "312211" (Previous had three 1s and two 2s and one 1s)

reyou
Автор

Thank you so much!!! I watched so many videos but couldnt understand how to write the code. After watching yours I understand it now!

abigaillee
Автор

great explanation, the slower the clearer I personally feel

ldwser
Автор

great explanation, i dint understand the question at first place

amitbhattacharyya
Автор

Best explanation for this question! Thank you for uploading!

nora
Автор

Great explanation. What is the time complexity for this problem?

Shiva-zyjq
Автор

amazing video, your video made it so clear and easy to understand, thank you so much! I really appreciate it!

quirkyquester
Автор

Great solution, what is the time complexity of this solution?

codingandmusical
Автор

why are we decreasing n in the ned? I thought since the row is starting from the beginning so it should be increasing n?

ldwser
Автор

could you code it in c++, it would be better to understand, though the logic pretty clear .

sunidhihegde
Автор

lol damn 7516 poeple hate this question.

Turnpost
Автор

you explain fine but its a little boring

financewithsom
Автор

// another solution, I guess faster
/**
* @param {number} n
* @return {string}
*/
var countAndSay = function (n) {
if (n === 1) return "1";

let finalResult = "1"

for (let i = 2; i <= n; i++) {
let stringInFocus = finalResult;
let currentResult = "";
let counter = 1;
let prevCharacterIndex = 0;
let currentCharacterIndex = 1;
while {
if (
===

) {
counter++;
} else {
currentResult =
prevCharacterIndex = currentCharacterIndex;
counter = 1;
}
currentCharacterIndex++;
}
currentResult =
finalResult = currentResult;
}
return finalResult;
};

shadmanmartinpiyal
visit shbcf.ru