Category: data structure
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 a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value …
Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. Example: MovingAverage m = new MovingAverage(3); m.next(1) = 1 …
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 …
August 31, 2020
algorithms, Binary Tree, c / c++, C/C++, code, data structure, interviews, Java, programming languages, Python
A Binary Search Tree (BST) is a commonly used data structure that can be used to search for an item in O(LogN) time. A BST has the following characteristics: …