Stupid Software Engineer Can't Solve Anything | 463. Island Perimeter

  Рет қаралды 880

Timothy Lee Grant

Timothy Lee Grant

Күн бұрын

Пікірлер: 13
@legitGamesSeason
@legitGamesSeason 21 күн бұрын
Bro, you can set up a neighbor counter helper function that looks up, down, left, and right and returns their sum. If you think about it, that's the neighbors' count. And the perimeter for every block would be 4 - neighbors count!
@CAT-hii
@CAT-hii 5 күн бұрын
Hello brother, subbed. Continue this leetcode solving series, also can you try to solve in java. Peace.
@TimothyLeeGrantEngineering
@TimothyLeeGrantEngineering 5 күн бұрын
Thank you for the comment and sub. I will not be stopping this leet code journey until it is accomplished! Regarding the language, which I am using, I specifically targeted using python because that is the language which I intend to use for these leet code kind of questions. Obviously Java is going to be extremely important for me to have a good grasp on and be able to use, but I think that Java language is Relegated to a different type of domain (more backend operations. That is why I am doing my projects in Java and trying to learn that language within the specific context which the Java language lives inside of.
@bladekiller2766
@bladekiller2766 16 күн бұрын
Wait until you try Codeforces, LC is way easier than Codeforces.
@TimothyLeeGrantEngineering
@TimothyLeeGrantEngineering 16 күн бұрын
If Leetcode is easy compared to Codeforces, then I can’t even imagine what Codeforces would be like! Is Codeforces the one you normally do?
@bladekiller2766
@bladekiller2766 16 күн бұрын
@TimothyLeeGrantEngineering I did in my high school years, now pretty rare, but it's way harder, Leetcode Hard is medium difficulty there. And you also have divisions, div3,4 are Leetcode level difficulty for begineers, div2 is the standard, and div1 are competing only the best competitive programmers in the world. Leetcode problems are quite straightforward and algorithmic, Codeforces are more creative puzzles that happen to have computational solution. BTW, you can solve the problem just going through each 1 cell and checking adjacent cells, if adj is out of grid or it's 0 you add it to the perimeter, it's another way of just checking the edges for each cell.
@CAT-hii
@CAT-hii 5 күн бұрын
@@TimothyLeeGrantEngineering Codeforces lower rating questions = Leetcode harder version problems. I can't even solve one in code forces.
@samdvc2735
@samdvc2735 22 күн бұрын
Hey bro do you do competitive programming also
@TimothyLeeGrantEngineering
@TimothyLeeGrantEngineering 19 күн бұрын
I haven’t done anything like that. I just started practicing leetcode a few months ago.
@zach6607
@zach6607 21 күн бұрын
Hey, you were super close!! For those wondering what piece of logic that Copilot added which OP did not add was, on around line 24 - 25, when visiting a node it checked while stack: i, j = stack.pop() # region Visit Check if (i, j) in visited: continue # end region I will try to post the full code soon
@zach6607
@zach6607 21 күн бұрын
KZbin is not allowing me to attach links to my leetcode solution based on OPs approach class Solution: def islandPerimeter(self, grid: List[List[int]]) -> int: if not grid: return 0 start: Coordinate = find_island(grid) if start is None: return 0 stack: List[Coordinate] = [] visited: set = set() stack.append(start) perim = 0 MAX_NEIGHBORS = 4 while stack: curr: Coordinate = stack.pop() visited.add(curr) neighbors: List[Coordinate] = get_neighbors(grid, curr) perim += MAX_NEIGHBORS - len(neighbors) unvisited: List[Coordinate] = list(filter(lambda n: n not in visited, neighbors)) visited.update(unvisited) stack += unvisited return perim class Coordinate(object): def __init__(self, row: int, col: int): self.row: int = row self.col: int = col def __eq__(self, other): if isinstance(other, Coordinate): return self.row == other.row and self.col == other.col return false def __hash__(self): return hash((self.row, self.col)) def __str__(self): return f'({self.row},{self.col})' def __repr__(self): return f'({self.row},{self.col})' def get_neighbors(grid: List[List[int]], curr: Coordinate) -> List[Coordinate]: neighbors: List[Coordinate] = [] row = curr.row col = curr.col land = 1 # check up if row is not 0 and grid[row - 1][col] is land: neighbors.append(Coordinate(row - 1, col)) # check down if row is not len(grid) - 1 and grid[row + 1][col] is land: neighbors.append(Coordinate(row + 1, col)) # check right if col is not 0 and grid[row][col - 1] is land: neighbors.append(Coordinate(row, col - 1)) # check left if col is not len(grid[row]) - 1 and grid[row][col + 1] is land: neighbors.append(Coordinate(row, col + 1)) return neighbors def find_island(grid: List[List[int]]) -> Coordinate: for row in range(len(grid)): for col in range(len(grid[row])): if grid[row][col] == 1: return Coordinate(row, col) return None
@zach6607
@zach6607 21 күн бұрын
I see OP made another video where they found this line! Love to see that you didn't get discouraged! Failing is part of learning in this field
@CAT-hii
@CAT-hii 5 күн бұрын
@@zach6607 What is OP?
Canadian took me inside a Chinese Factory... I Didn’t Expect This
28:05
Successful Leetcode Adventure: 349. Intersection of Two Arrays
51:37
Timothy Lee Grant
Рет қаралды 172
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
EOS in Atomic Simulation Environment and Quantum ESPRESSO
11:24
Tech_New_ Stuff
Рет қаралды 178
ChatGPT has returned. Run.
20:51
GothamChess
Рет қаралды 505 М.
Why Americans Can’t Find Starter Homes
10:58
CNBC
Рет қаралды 584 М.
How a Blind Mathematician Became the World's Greatest
16:31
Newsthink
Рет қаралды 144 М.
How To Get a Free Azure SQL Database
45:57
IAmTimCorey
Рет қаралды 6 М.
The College Enrollment Crisis
17:26
PolyMatter
Рет қаралды 643 М.
Software Engineering Completeness - Peter Muldoon - Meeting C++ 2024
1:00:46
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН