DFS With Slashes - Coding Interview Stream Highlights
Вставка
- Опубліковано 15 жов 2020
- Highlights of Thursday Coding Interview live-stream.
I'm streaming regularly on Twitch now! Coding interview problems on Thursday, and Competitive Programming on Tuesday & Saturday. / errichto
Problem link: leetcode.com/problems/regions...
Watch the full VOD here: • Coding Interviews Are ...
- second YT channel for screencasts and old live-streams: / errichto2
- FB and Twitter: / errichto & / errichto
- Frequently Asked Questions: github.com/Errichto/youtube/w...
Tune in any Thursday on www.twitch.tv/errichto for coding interview problem-solving!
(or Tuesday/Saturday for competitive programming)
and once Kamil , you said : what's life if you don't do anything for others, life is about creating an impact in the world, smaller or bigger🌻.You have definitely created an impact, not only as a competitive programmer but also as a mentor and human being.💛
Thank you for these nice words :)
Could you explain why your XOR logic works? I don't understand how you came to that conclusion so quickly
You are awesome!
PS: Where should I start from to get into CP? I have 0 knowledge of C++ and watching you code like that have boosted my confidence!
tyy
well, first learn C++ by doing any tutorial online
Sir, I want to learn CPP for competitive programming, what book should I choose for learning CPP from beginning to advance?
My knowledge in CPP is 0.
Once you start explaining, Its damn easy. How come I didn't think of that!!
Finally understood it.
Thanks.
Having so much knowledge and making a dumb person like me understand requires great teaching capabilities.
Thanks a lot!
very good explanation
this guy killed it !!
Thanks!
Wow, You really are at another level.
Your typing has become so swift and accurate.
Was it ever different? ;p
@@Errichto no, but it has now become even better and very faster.
How long have you been doing this?
Hello,Errichto..can you make a video about base-n's in programming..please..
Errichto : Soon I will be regaining LGM.
Enter Among us.........
What place do you recommend to learn basic properties about vectors, maps, dfs, bfs etc. (dont even know what those last two are) Im overall new to coding so Im still discovering more and more techniques/types of storing informations/algorithm functions etc.
//Ze wzgledu na moj biedny angielski:
W skrocie - gdzie polecalbys uczyc sie nie tyle umiejetnosci logicznego myslenia, rozwiazywania problemow, co samej skladni jezyka, w tym najbardziej przydatnych obiektow, funkcji itd.
Any C++ tutorial online. I learned 10 years ago, those websites don't even exist anymore.
14:37 here how did you come up with ^ logic ? Amazing
Hi Brother! You got a new subscriber today and i have a ques--Is dynamic programming recommended for beginners? I know c++ and a few algorithms (& have lot of patience also :))
Nah, you can wait with dp for quite some time.
OK I will start dp at the end of November
What is the name of IDE that Errichto uses?
Geany
Which mechanical keyboard you are using?
none : ___ :
like it so much
Didn't get the XOR part... Can anybody please explain that part?
0^1-> 1
1^1-> 0
It's just like swaping 0 and 1 every time
your linkdin id??
idol!
Those who are asking what errichto does for living just check his linkedin profile.
Kuch Nahi Mila Bhai...comment me.link Dal
i had no idea what im watching .just understand few statement liek if and void @@.is this java @@
It's never too late to put bumbags into your style, Kamil
How to increase solving speed in cf Problem-c,d
Practice. What other answer could you possible expect? :/
@@Errichto any other tricks probably 😅 I am good at long challenges (5* @ codechef) but didn't able to solve fast enough so I lacked in short contests.
@@abdurrahaman388 My general "how to practice" advice is here github.com/Errichto/youtube/wiki/How-to-practice%3F
Should I do maths first or DSA?
definitely DSA
If you suck at school math, maybe catch up with that first before learning DSA.
@@Errichto maths of Class 8 to 10th right??
@@dashgaming3713 I don't know. Just solve easy algo problems and see if you lack some math knowledge.
Errichto, will you play "among us" in your discord server with some noob programmers like me. :)
Well, I already did ;p
I don't know if I will play again, we'll see.
How much years does it take to become a red coder??
I think errichto went from 0 to red in 6 months
2-5 years if you already know programming and you are very good at math. It's a bit like asking "how many years to get to the national football team". Some people can try and never get there.
@@Errichto for a bigginer ?? I want to crack kickstart and code jam lol
Can you make full roadmap like video to learn programming language to become red coder
Go to Codeforces, sort problems by difficulty, solve them in this order.
You're welcome :D
If you want some serious advice, read this github.com/Errichto/youtube/wiki/How-to-practice%3F
what is your IQ level?
if you have to ask...
I have piles
First?
Errichto help me I don't understand DSA at all :(
Clean Code
```
class Solution(object):
def regionsBySlashes(self, grid):
"""
:type grid: List[str]
:rtype: int
"""
n = len(grid)
# Create a visited matrix for each small triangle in the 2n x 2n grid
visited = [[False] * (n * 3) for _ in range(n * 3)]
def dfs(x, y):
if x < 0 or x >= n * 3 or y < 0 or y >= n * 3 or visited[x][y]:
return
visited[x][y] = True
directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
for dx, dy in directions:
dfs(x + dx, y + dy)
# Mark the slashes in the 2n x 2n grid
for i in range(n):
for j in range(n):
if grid[i][j] == '/':
visited[i * 3][j * 3 + 2] = True
visited[i * 3 + 1][j * 3 + 1] = True
visited[i * 3 + 2][j * 3] = True
elif grid[i][j] == '\\':
visited[i * 3][j * 3] = True
visited[i * 3 + 1][j * 3 + 1] = True
visited[i * 3 + 2][j * 3 + 2] = True
regions = 0
for i in range(n * 3):
for j in range(n * 3):
if not visited[i][j]:
dfs(i, j)
regions += 1
return regions
```