Fingerprint Location for Bluetooth

Fingerprint-based Bluetooth Localization (Fingerprint-based Bluetooth Localization) is a commonly used indoor positioning algorithm. Its basic principle is to establish a fingerprint database by recording the Bluetooth signal strength values at different locations, and then according to the Bluetooth signal strength values received by the device, Match the most similar fingerprints to determine where the device is located.

Read More

Tree Traversals BFS

102. Binary Tree Level Order Traversal

a. BFS solution

Read More

Tree Traversals DFS

94. Binary Tree Inorder Traversal

a. Recursive solution

Read More

Heap and Heap Sort

A Heap is a special Tree-based data structure in which the tree is a complete binary tree. Generally, there are two types of Heap: Max-Heap (root node is greater than its child nodes) and Min-Heap (root node is smaller than its child nodes).

Read More

Query with Stack

20. Valid Parentheses

We can simply iterate over all items from the given string and compare the adjacent values each time with the help of stack before pushing the element in.

Read More

Design a Stack with Queue

225. Implement Stack using Queues

We can’t use the similar solution we did for Design a Queue with Stack. It is because unlike Stack, moving elements from one Queue to another one won’t change the sequence of elements. We have to pop out all previous elements added into the queue when adding a new element, in this way we can simulate a Stack.

Read More

Design a Queue with Stack

232. Implement Queue using Stacks

Since Queue is FIFO but Stack is FILO. If we need to use Stack to implement a Queue, we need to use at least two Stacks. So we use one stack which only handle Push operations, and another Stack which only handle Pop/Peek operations. And we move elements from the Pop only Stack to the other one when Pop/Peek get called. It will reverse the FILO stack elements sequence after that. So we get a FIFO sequence.

Read More

String Match with KMP Algorithm

Search if a given string pattern (needle) is part of a target string (haystack) is a common problem. The naive approach is to use two nested loops with O(n * m) time complexity. KMP is a better way which has a better performance.

Read More

Two Pointers

  1. Array Elements In-Placed Removal

Let’s take a look at a easy problem on Leetcode 27. Remove Element. We will demonstrate how to remove an element from an array without allocating extra space for another array.

Read More

Common Items Quick Search with Array and HashMap

Usually when you get a problem about searching the common items between multiple strings, the brute-force solution’s time complexity is usually too high. We can use hashmap to lower the time complexity.

Read More