Longest Common Prefix in C++

Longest Common Prefix in C++ (LeetCode 14: Longest Common Prefix) is one of the most foundational string comparison and prefix search problems tested in technical interviews at top engineering firms including Google, Amazon, Microsoft, Apple, and Adobe. Given an array of strings strs, the objective is to determine the longest prefix string that is shared …

Reverse Words in a String in C++

Reverse Words in a String in C++ (LeetCode 151: Reverse Words in a String) is one of the most frequently tested string manipulation and two-pointer problems in technical interviews at top-tier companies including Amazon, Microsoft, Google, Apple, Meta, and Bloomberg. You are given an input string s consisting of words separated by spaces. The objective …

Remove Outermost Parentheses in C++

Remove Outermost Parentheses in C++ (LeetCode 1021: Remove Outermost Parentheses) is a classic string parsing and stack-based balance problem frequently tested in technical interviews at companies like Amazon, Microsoft, Adobe, Google, and Bloomberg. A valid parentheses string s is defined as primitive if it is non-empty and cannot be split into two or more non-empty …

Rotate Image (90 Degrees Clockwise) in C++

Rotate Image in C++ (LeetCode 48: Rotate Image) is a classic 2D matrix transformation problem frequently featured in technical interviews at top tier technology companies such as Google, Amazon, Microsoft, Apple, Meta, and Bloomberg. You are given an N × N 2D matrix representing an image where each cell represents a pixel. The objective is …

Sort K-Sorted Array in C++

Sort K-Sorted Array in C++ (also known as Sort a Nearly Sorted Array) is a classic algorithmic problem frequently tested in technical interviews at top software engineering firms and quant trading shops including Google, Amazon, Microsoft, Citadel, Jane Street, Goldman Sachs, and Bloomberg. In a K-Sorted Array of length N, every single element is at …

Replace Each Element by Its Rank in C++

Replace Each Element by Its Rank in C++ (LeetCode 1331: Rank Transform of an Array) is a classic coordinate compression and sorting problem frequently featured in technical interviews at top software engineering firms including Amazon, Microsoft, Adobe, Bloomberg, and Google. Given an array of integers arr, the algorithmic objective is to replace each element with …

Spiral Matrix in C++

Spiral Matrix in C++ (LeetCode 54: Spiral Matrix) is one of the most foundational and frequently asked 2D array manipulation and boundary-tracking problems featured in technical interviews at top technology firms such as Amazon, Microsoft, Apple, Google, Meta, and Bloomberg. Given a 2D matrix of dimensions M × N, the objective is to traverse and …

Search a 2D Matrix in C++

Search a 2D Matrix in C++ (LeetCode 74: Search a 2D Matrix and LeetCode 240: Search a 2D Matrix II) is a quintessential algorithmic problem featured in technical interviews at premier technology firms such as Google, Amazon, Microsoft, Apple, Meta, and Bloomberg. Searching multi-dimensional grids efficiently forms the core foundation of spatial database indexing, 2D …

Row with Maximum 1โ€™s in C++

Row with Maximum 1โ€™s in C++ is a foundational 2D matrix algorithmic problem frequently featured in technical interviews at top-tier companies such as Amazon, Microsoft, Adobe, Flipkart, and Goldman Sachs. You are given a 2D boolean matrix of dimensions M × N where every individual row is sorted in non-decreasing order (meaning all 0s appear …