LeetCode: 1857-Largest Color Value in a Directed Graph 解題紀錄
題目
There is a directed graph of n
colored nodes and m
edges. The nodes are numbered from 0
to n - 1
.
There is a directed graph of n
colored nodes and m
edges. The nodes are numbered from 0
to n - 1
.
Given an integer array nums
, return the number of subarrays filled with 0
.
You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots.
Read More »LeetCode: 605-Can Place Flowers 解題紀錄For two strings s
and t
, we say "t
divides s
" if and only if s = t + ... + t
(i.e., t
is concatenated with itself one or more times).
Given an undirected tree consisting of n
vertices numbered from 0
to n-1
, which has some apples in their vertices. You spend 1 second to walk over one edge of the tree. Return the minimum time in seconds you have to spend to collect all apples in the tree, starting at vertex 0 and coming back to this vertex.
Given the roots of two binary trees p
and q
, write a function to check if they are the same or not.
Two binary trees are considered the same if they are structurally identical, and the nodes have the same value.
Read More »LeetCode: 100-Same Tree 解題紀錄You are given a 0-indexed integer array tasks
, where tasks[i]
represents the difficulty level of a task. In each round, you can complete either 2 or 3 tasks of the same difficulty level.
You are given an array of n
strings strs
, all of the same length.