100 articles · page 9 of 23
Set Matrix Zeros
class Solution { public: void setMatrixZeroes(vector<vector<int>> &mat) { int n = mat.size(); int m …
Zigzag string conversion solution in C++
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this Input: s = "PAY…
Search Sorted Matrix Solution in C++
The idea here is to implement binary search after discovering the correct row. #include <bits/stdc++.h> usi…
LeetCode 543 Diameter of a Binary Tree in C++
Given the root of a binary tree, return the length of the diameter of the tree. The&n…
401. Binary Watch
A binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent …
Letter Combinations of a phone number
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that th…
LeetCode 20 Valid Parentheses in Typescript
The mental challenge one might experience here is that JavaScript doesn't have abstract data structures like s…
Max Chunks To Make Sorted
You are given an integer array arr of length n that represents a permutation of the intege…
Final Prices With a Special Discount in a Shop
You are given an integer array prices where prices[i] is the price of the ith it…
C++ Solution for Generate Parentheses Leetcode Problem #22
Given n pairs of parentheses, write a function to generate all combinations of well-formed pare…
Final Array State After K Multiplication Operations
You are given an integer array nums, an integer k, and an integer multiplier. You need to perfo…
Minimum Characters to Add for Palindrome: Algorithms & Solutions
A complete algorithmic guide to solving the Minimum Characters to Add for Palindrome problem in O(N) linear ti…
