How to Perform a Counting Using Array and Hash Table

A simple C++ solution to Leetcode 387. First Unique Character in a String.

How To Shift Elements of a Matrix

How to convert a 2D grid to a 1D vector to make the shifting operations simpler. The modulo operator helps loop back to the start of the vector after k shifts.

How Long To Reach A Warmer Day

Two C++ approaches for solving Leetcode 739. Daily Temperatures. The first one uses nested loops with O(N^2) runtime. The second one reduces the runtime to O(N) by using only one loop.

How To Arrange An Array In Parity

Two approaches for solving Leetcode 922. Sort Array By Parity II. One uses Buble sort, which takes O(N^2) runtime. The other uses the Two-pointer technique to reduce runtime to O(N).

How to Rotate a Square Matrix

A simple solution to LeetCode Challenge 48. Rotate Image. The math behind is rotating a matrix by 90 degrees can be done by following 2 steps: transpose the matrix, then mirror the matrix vertically.

How To Remove Duplicates From a Sorted Array

Two approaches for solving Leetcode Challenge 80. Remove Duplicates from Sorted Array II. The key is to either erase duplicates beyond two occurrences while preserving order or reassign valid elements (up to two of each) to the first k indexes of nums.