Maximum Depth of an N-ary Tree
Find the maximum depth of an N-ary tree.
Input: root = [1,null,2,null,3,null,4]
Output: 4
Explanation: The tree is essentially a straight line, requiring a traversal that reaches a maximum depth of 4 layers.
Find the shortest path visiting all nodes in a graph.
You have an undirected, connected graph of n nodes. Return the length of the shortest path that visits every node. You may start and stop at any node, you may revisit nodes multiple times, and you may reuse edges.
Input: graph = [[1],[0,2],[1]]
Output: 2
Explanation: The graph is a…
Count Anagrammatic Substrings
Count the number of anagrammatic substrings from one string present in another.
Input: s = "abab", p = "ab"
Output: [0, 1, 2]
Explanation: The substrings "ab", "ba", and "ab" starting at indices 0, 1, and 2 respectively are all anagrams of the string "ab".