Tag: hash map
Given a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring return -1. A substring …
Given two sparse vectors, compute their dot product. Implement class SparseVector: SparseVector(nums) Initializes the object with the vector nums dotProduct(vec) Compute the dot product between the instance of SparseVector …
Given a root of an N-ary tree, return a deep copy (clone) of the tree. Each node in the n-ary tree contains a val (int) and a list (List) …
A binary tree is given such that each node contains an additional random pointer which could point to any node in the tree or null. Return a deep copy …
Given an array of integers nums and an integer k. A subarray is called nice if there are k odd numbers on it. Return the number of nice sub-arrays. …