본문 바로가기

뇌세포덩어리""/알고리즘

[leetcode] dfs / bfs 재밌는 문제들

 

 

https://leetcode.com/problems/surrounded-regions/

 

Surrounded Regions - LeetCode

Surrounded Regions - Given an m x n matrix board containing 'X' and 'O', capture all regions that are 4-directionally surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region.   Example 1: [https://assets.leetcode.

leetcode.com

https://leetcode.com/problems/count-servers-that-communicate/

 

Count Servers that Communicate - LeetCode

Count Servers that Communicate - You are given a map of a server center, represented as a m * n integer matrix grid, where 1 means that on that cell there is a server and 0 means that it is no server. Two servers are said to communicate if they are on the

leetcode.com

 

 

https://leetcode.com/problems/shortest-bridge/

 

Shortest Bridge - LeetCode

Shortest Bridge - You are given an n x n binary matrix grid where 1 represents land and 0 represents water. An island is a 4-directionally connected group of 1's not connected to any other 1's. There are exactly two islands in grid. You may change 0's to 1

leetcode.com

 

https://leetcode.com/problems/detonate-the-maximum-bombs/description/

 

Detonate the Maximum Bombs - LeetCode

Detonate the Maximum Bombs - You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb. The bombs are represented by a 0-indexed

leetcode.com

 

 

https://leetcode.com/problems/cheapest-flights-within-k-stops/description/

 

Cheapest Flights Within K Stops - LeetCode

Cheapest Flights Within K Stops - There are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is a flight from city fromi to city toi with cost pricei. You are also giv

leetcode.com

 

 

https://leetcode.com/problems/all-paths-from-source-to-target/description/

 

All Paths From Source to Target - LeetCode

All Paths From Source to Target - Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any order. The graph is given as follows: graph[i] is a list of all nodes you ca

leetcode.com

 

https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/

 

Most Stones Removed with Same Row or Column - LeetCode

Most Stones Removed with Same Row or Column - On a 2D plane, we place n stones at some integer coordinate points. Each coordinate point may have at most one stone. A stone can be removed if it shares either the same row or the same column as another stone

leetcode.com

 

 

https://leetcode.com/problems/alphabet-board-path/description/

 

Alphabet Board Path - LeetCode

Alphabet Board Path - On an alphabet board, we start at position (0, 0), corresponding to character board[0][0]. Here, board = ["abcde", "fghij", "klmno", "pqrst", "uvwxy", "z"], as shown in the diagram below. [https://assets.leetcode.com/uploads/2019/07/

leetcode.com

 

 

https://leetcode.com/problems/map-of-highest-peak/

 

Map of Highest Peak - LeetCode

Can you solve this real interview question? Map of Highest Peak - You are given an integer matrix isWater of size m x n that represents a map of land and water cells. * If isWater[i][j] == 0, cell (i, j) is a land cell. * If isWater[i][j] == 1, cell (i, j)

leetcode.com

 

 

https://leetcode.com/problems/rotting-oranges/