随笔分类 -  DFS

摘要:There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct 阅读全文
posted @ 2020-03-11 12:18 北叶青藤 阅读(274) 评论(0) 推荐(0)
摘要:You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose o 阅读全文
posted @ 2019-08-19 03:51 北叶青藤 阅读(268) 评论(0) 推荐(0)
摘要:Recurrence Algorithm Big-Oh Solution T(n) = T(n/2) + O(1) Binary SearchO(log n)T(n) = T(n-1) + O(1) Sequential SearchO(n)T(n) = 2 T(n/2) + O(1) Tree T 阅读全文
posted @ 2019-08-19 01:43 北叶青藤 阅读(189) 评论(0) 推荐(0)
摘要:Given a 01 matrix M, find the longest line of consecutive one in the matrix. The line could be horizontal, vertical, diagonal or anti-diagonal. Exampl 阅读全文
posted @ 2019-08-16 12:18 北叶青藤 阅读(205) 评论(0) 推荐(0)
摘要:Let's play the minesweeper game (Wikipedia, online game)! You are given a 2D char matrix representing the game board. 'M' represents an unrevealed min 阅读全文
posted @ 2019-08-08 14:41 北叶青藤 阅读(702) 评论(0) 推荐(0)