Tag LLVM

Write an LLVM Pass

In this post, I will show how I write an...


Tag Hash Table

Sum Of Unique Elements Problem

LeetCode 1748. You are given an integer array nums. The...

Insert Delete GetRandom O(1) Problem

LeetCode 380. Implement a RandomizedSet class.

N-Repeated Element In Size 2N Array Problem

LeetCode 961. In a array A of size 2N, there...

Intersection Of Two Arrays Problem

LeetCode 349. Given two arrays, write a function to compute...

Intersection Of Three Sorted Arrays Problem

LeetCode 1213. Given three integer arrays arr1, arr2 and arr3...

Jewels And Stones Problem

LeetCode 771. You’re given strings jewels representing the types of...

Number Of Good Pairs Problem

LeetCode 1512. Given an array of integers nums. Return the...

Kth Missing Positive Number Problem

LeetCode 1539. Given an array arr of positive integers sorted...

Maximum Equal Frequency Problem

LeetCode 1224. Given an array nums of positive integers, return...

Subarray Sum Divisible By K Problem

LeetCode 974. Given an array of integers nums and an...

Four Sum II Problem

LeetCode 454. Given four lists A, B, C, D of...

Continuous Subarray Sum Problem

LeetCode 523. Given an array of non-negative integers nums and...

Subarray Sum Equals K Problem

LeetCode 560. Given an array of integers nums and an...

Two Sum Problem

LeetCode 1. Given an array of integers nums and an...

Tag Leetcode

Rearrange Products Table Problem

LeetCode 1795. Write an SQL query to rearrange the Products...

Find Interview Candidates Problem

LeetCode 1811. Write an SQL query to report the name...

Determine Color Of A Chessboard Square Problem

LeetCode 1812. You are given coordinates, a string that represents...

Ad-Free Sessions Problem

LeetCode 1809. Write an SQL query to report all the...

String To Interger (atoi) Problem

LeetCode 8. Implement the myAtoi(string s) function, which converts a...

Primary Department For Each Employee Problem

LeetCode 1789. Write an SQL query to report all the...

Grand Slam Titles Problem

LeetCode 1783. Write an SQL query to report the number...

Product's Price For Each Store Problem

LeetCode 1777. Write an SQL query to find the price...

Find The Subtasks That Did Not Execute Problem

LeetCode 1767. Write an SQL query to report the IDs...

Add Two Numbers Problem

LeetCode 2. You are given two non-empty linked lists representing...

Sum Of Unique Elements Problem

LeetCode 1748. You are given an integer array nums. The...

Recyclable And Low Fat Products Problem

LeetCode 1757. Write an SQL query to find the ids...

Leetflex Banned Accounts Problem

LeetCode 1747. Write an SQL query to find the account_id...

Insert Delete GetRandom O(1) Problem

LeetCode 380. Implement a RandomizedSet class.

N-Repeated Element In Size 2N Array Problem

LeetCode 961. In a array A of size 2N, there...

Intersection Of Two Arrays Problem

LeetCode 349. Given two arrays, write a function to compute...

Intersection Of Three Sorted Arrays Problem

LeetCode 1213. Given three integer arrays arr1, arr2 and arr3...

Find Total Time Spent By Each Employee Problem

LeetCode 1741. Write an SQL query to calculate the total...

Jewels And Stones Problem

LeetCode 771. You’re given strings jewels representing the types of...

Number Of Good Pairs Problem

LeetCode 1512. Given an array of integers nums. Return the...

Kth Missing Positive Number Problem

LeetCode 1539. Given an array arr of positive integers sorted...

The Number Of Employees Which Report To Each Employee Problem

LeetCode 1731. Write an SQL query to report the ids...

Find Followers Count Problem

LeetCode 1729. Write an SQL query that will, for each...

Count Apples And Oranges Problem

LeetCode 1715. Write an SQL query to count the number...

Biggest Window Between Visits Problem

LeetCode 1709. Write an SQL query that will, for each...

Total Sales Amount By Year Problem

LeetCode 1384. Write an SQL query to report the Total...

Sales By Day Of The Week Problem

LeetCode 1479. Write an SQL query to report how many...

Hopper Company Queries III Problem

LeetCode 1651. Write an SQL query to compute the average_ride_distance...

Get The Second Most Recent Activity Problem

LeetCode 1369. Write an SQL query to show the second...

Find The Quiet Students In All Exams Problem

LeetCode 1412. Write an SQL query to report the students...

Tournament Winners Problem

LeetCode 1194. Write an SQL query to find the winner...

Students Report By Geography Problem

LeetCode 618. A U.S graduate school has students from Asia,...

Report Contiguous Dates Problem

LeetCode 1225. Write an SQL query to generate a report...

Median Employee Salary Problem

LeetCode 569. Write a SQL query to find the median...

Market Analysis II Problem

LeetCode 1159. Write an SQL query to find for each...

Hopper Company Queries I Problem

LeetCode 1635. Write an SQL query to report the following...

Game Play Analysis V Problem

LeetCode 1097. Write an SQL query that reports for each...

User Purchase Platform Problem

LeetCode 1127. Write an SQL query to find the total...

Trips And Users Problem

LeetCode 262. Write a SQL query to find the cancellation...

Number Of Transactions Per Visit Problem

LeetCode 1336. Write an SQL query to find how many...

Human Traffic Of Stadium Problem

LeetCode 601. Write an SQL query to display the records...

Hopper Company Queries II Problem

LeetCode 1645. Write an SQL query to report the percentage...

Find Median Given Frequency Of Numbers Problem

LeetCode 571. Write a query to find the median of...

Find Cumulative Salary Of An Employee Problem

LeetCode 579. Write a SQL to get the cumulative sum...

Department Top Three Salaries Problem

LeetCode 185. Write a SQL query to find employees who...

Average Salary: Departments VS Company Problem

LeetCode 615. Given two tables as below, write a query...

Unpopular Books Problem

LeetCode 1098. Write an SQL query that reports the books...

Second Degree Follower Problem

LeetCode 614. Please write a sql query to get the...

Reported Posts II Problem

LeetCode 1132. Write an SQL query to find the average...

Number Of Calls Between Two Persons Problem

LeetCode 1699. Write an SQL query to report the number...

Nth Highest Salary Problem

LeetCode 177. Write a SQL query to get the nth...

New Users Daily Count Problem

LeetCode 1107. Write an SQL query that reports for every...

Monthly Transactions II Problem

LeetCode 1205. Write an SQL query to find for each...

Get Highest Answer Rate Question Problem

LeetCode 578. Write a sql query to identify the question...

Department Highest Salary Problem

LeetCode 184. Write a SQL query to find employees who...

Article Views II Problem

LeetCode 1149. Write an SQL query to find all the...

Active Users Problem

LeetCode 1454. Write an SQL query to find the id...

Winning Candidate Problem

LeetCode 574. Write a sql to find the name of...

Team Scores In Football Tournament Problem

LeetCode 1212. Write an SQL query that selects the team_id,...

Rank Scores Problem

LeetCode 178. Write a SQL query to rank scores. If...

Product Sales Analysis III Problem

LeetCode 1070. Write an SQL query that selects the product...

Movie Rating Problem

LeetCode 1341. Write the following SQL query to find the...

Investments In 2016 Problem

LeetCode 585. Write a query to print the sum of...

Immediate Food Delivery II Problem

LeetCode 1174. Write an SQL query to find the percentage...

Friend Requests II: Who Has The Most Friends Problem

LeetCode 602. In social network like Facebook or Twitter, people...

Countries You Can Safely Invest In Problem

LeetCode 1501. Write an SQL query to find the countries...

Count Student Number In Departments Problem

LeetCode 580. A university uses 2 data tables, student and...

Bank Account Summary Problem

LeetCode 1555. Our bank records all transactions in the table...

Tree Node Problem

LeetCode 608. Given a table tree, id is identifier of...

The Most Recent Orders For Each Product Problem

LeetCode 1549. Write an SQL query to find the most...

Shortest Distance In A Plane Problem

LeetCode 612. Write a query to find the shortest distance...

Rectangles Area Problem

LeetCode 1459. Write an SQL query to report of all...

Product Price At A Given Date Problem

LeetCode 1164. Write an SQL query to find the prices...

Page Recommendations Problem

LeetCode 1264. Write an SQL query to recommend pages to...

Monthly Transactions I Problem

LeetCode 1193. Write an SQL query to find for each...

Market Analysis I Problem

LeetCode 1158. Write an SQL query to find for each...

Managers With At Least 5 Direct Reports Problem

LeetCode 570. Given the Employee table, write a SQL query...

Find The Missing IDs Problem

LeetCode 1613. Write an SQL query to find the missing...

Exchange Seats Problem

LeetCode 626. Mary is a teacher in a middle school...

Customers Who Bought All Products Problem

LeetCode 1045. Write an SQL query for a report that...

Active Business Problem

LeetCode 1126. Write an SQL query to find all active...

The Most Recent Three Orders Problem

LeetCode 1532. Write an SQL query to find the most...

Restaurant Growth Problem

LeetCode 1321. You are the restaurant owner and you want...

Project Employees III Problem

LeetCode 1077. Write an SQL query that reports the most...

Number Of Trusted Contacts Of A Customer Problem

LeetCode 1364. Write an SQL query to find the following...

NPV Queries Problem

LeetCode 1421. Write an SQL query to find the npv...

Last Person To Fit In The Elevator Problem

LeetCode 1204. Write an SQL query to find the person_name...

Highest Grade For Each Student Problem

LeetCode 1112. Write a SQL query to find the highest...

Evaluate Boolean Expression Problem

LeetCode 1440. Write an SQL query to evaluate the boolean...

Calculate Salaries Problem

LeetCode 1468. Write an SQL query to find the salaries...

Activity Participants Problem

LeetCode 1355. Write an SQL query to find the names...

User Activity For The Past 30 Days II Problem

LeetCode 1142. Write an SQL query to find the average...

The Most Frequently Ordered Products For Each Customer Problem

LeetCode 1596. Write an SQL query to find the most...

Running Total For Different Genders Problem

LeetCode 1308. Write an SQL query to find the total...

Friendly Movies Streamed Last Month Problem

LeetCode 1495. Write an SQL query to report the distinct...

Friend Requests I: Overall Acceptance Rate Problem

LeetCode 597. Write an SQL query to find the overall...

Find The Start And End Number Of Continuous Ranges Problem

LeetCode 1285. Write an SQL query to find the start...

Customers Who Bought Products A And B But Not C Problem

LeetCode 1398. Write an SQL query to report the customer_id...

Classes More Than 5 Students Problem

LeetCode 596. Please list out all classes which have more...

Capital Gain/Loss Problem

LeetCode 1393. Write an SQL query to report the Capital...

Biggest Single Number Problem

LeetCode 619. Table my_numbers contains many numbers in column num...

Apples & Oranges Problem

LeetCode 1445. Write an SQL query to report the difference...

All People Report To The Given Manager Problem

LeetCode 1270. Write an SQL query to find employee_id of...

Weather Type In Each Country Problem

LeetCode 1294. Write an SQL query to find the type...

User Activity For The Past 30 Days I Problem

LeetCode 1141. Write an SQL query to find the daily...

Triangle Judgement Problem

LeetCode 610. A pupil Tim gets homework to identify whether...

Students And Examinations Problem

LeetCode 1280. Write an SQL query to find the number...

Sales Person Problem

LeetCode 607. Given three tables, salesperson, company, orders.

Sales Analysis III Problem

LeetCode 1084. Write an SQL query that reports the products...

Sales Analysis II Problem

LeetCode 1083. Write an SQL query that reports the buyers...

Reported Posts Problem

LeetCode 1113. Write an SQL query that reports the number...

Queries Quality And Percentage Problem

LeetCode 1211. Write an SQL query to find each query_name,...

Project Employees II Problem

LeetCode 1076. Write an SQL query that reports all the...

Project Employees I Problem

LeetCode 1075. Write an SQL query that reports the average...

Number Of Comments Per Post Problem

LeetCode 1241. Write an SQL query to find number of...

Not Boring Movies Problem

LeetCode 620. X city opened a new cinema, many people...

Fix Product Name Format Problem

LeetCode 1543. Write an SQL query to report product_name in...

Consecutive Available Seats Problem

LeetCode 603. Several friends at a cinema ticket office would...

Ads Performance Problem

LeetCode 1322. A company is running Ads and wants to...

Top Travellers Problem

LeetCode 1407. Write an SQL query to report the distance...

Swap Salary Problem

LeetCode 627. Given a table salary, such as the one...

Shortest Distance Problem

LeetCode 613. Write a query to find the shortest distance...

Sales Analysis I Problem

LeetCode 1082. Write an SQL query that reports the best...

Reformat Department Table Problem

LeetCode 1179. Write an SQL query to reformat the table...

Product Sales Analysis II Problem

LeetCode 1069. Write an SQL query that reports the total...

Product Sales Analysis I Problem

LeetCode 1068. Write an SQL query that reports all product...

List The Products Ordered In A Period Problem

LeetCode 1327. Write an SQL query to get the names...

Immediate Food Delivery I Problem

LeetCode 1173. Write an SQL query to find the percentage...

Find Users With Valid Emails Problem

LeetCode 1517. Write an SQL query to find the users...

Find Customer Referee Problem

LeetCode 584. Given a table customer holding customers information and...

Customer Placing The Largest Number Of Orders Problem

LeetCode 586. Query the customer_number from the orders table for...

Customer Order Frequency Problem

LeetCode 1511. Write an SQL query to report the customer_id...

Create A Session Bar Chart Problem

LeetCode 1435. You want to know how long a user...

Big Countries Problem

LeetCode 595. Write a SQL solution to output big countries’...

Average Selling Price Problem

LeetCode 1251. Write an SQL query to find the average...

Article Views I Problem

LeetCode 1148. Write an SQL query to find all the...

Actors And Directors Who Cooperated At Least Three Times Problem

LeetCode 1050. Write a SQL query for a report that...

Unique Orders And Customers Per Month Problem

LeetCode 1565. Write an SQL query to find the number...

Sellers With No Sales Problem

LeetCode 1607. Write an SQL query to report the names...

Rising Temperature Problem

LeetCode 197. Write an SQL query to find all dates’...

Game Play Analysis IV Problem

LeetCode 550. Write an SQL query that reports the fraction...

Game Play Analysis III Problem

LeetCode 534. Write an SQL query that reports for each...

Game Play Analysis II Problem

LeetCode 512. Write a SQL query that reports the device...

Game Play Analysis I Problem

LeetCode 511. Write an SQL query that reports the first...

Employee Bonus Problem

LeetCode 577. Select all employee’s name and bonus whose bonus...

Delete Duplicate Emails Problem

LeetCode 196. Write a SQL query to delete all duplicate...

Daily Leads And Partners Problem

LeetCode 1693. Write an SQL query that will, for each...

Customer Who Visited But Did Not Make Any Transactions Problem

LeetCode 1581. Write an SQL query to find the IDs...

Product's Worth Over Invoices Problem

LeetCode 1677. Write an SQL query that will, for all...

Percentage Of Users Attended A Contest Problem

LeetCode 1633. Write an SQL query to find the percentage...

Fix Names In A Table Problem

LeetCode 1667. Write an SQL query to fix the names...

Duplicate Emails Problem

LeetCode 182. Write a SQL query to find all duplicate...

Customers Who Never Order Problem

LeetCode 183. Write a SQL query to find all customers...

Consecutive Numbers Problem

LeetCode 180. Write an SQL query to find all numbers...

Average Time Of Process Per Machine Problem

LeetCode 1661. There is a factory website that has several...

Second Highest Salary Problem

LeetCode 176. Given the Employee table, write a SQL query...

Employees Earning More Than Their Managers Problem

LeetCode 181. Given the Employee table, write a SQL query...

Bank Account Summary II Problem

LeetCode 1587. Write an SQL query to report the name...

Group Sold Products By The Date Problem

LeetCode 1484. Write an SQL query to find for each...

All Valid Triplets That Can Represent A Country Problem

LeetCode 1623. Write an SQL query to find all the...

Warehouse Manager Problem

LeetCode 1571. Write an SQL query to report how much...

Students With Invalid Departments Problem

LeetCode 1350. Write an SQL query to find the id...

Replace Employee ID With The Unique Identifier Problem

LeetCode 1378. Write an SQL query to show the unique...

Patients With A Condition Problem

LeetCode 1527. Write an SQL query to report the patient_id,...

Invalid Tweets Problem

LeetCode 1683. Write an SQL query to find the IDs...

Find The Team Size Problem

LeetCode 1303. Write an SQL query to find the team...

Combine Two Tables Problem

LeetCode 175. Write a SQL query for a report that...

Maximum Equal Frequency Problem

LeetCode 1224. Given an array nums of positive integers, return...

Number of Islands Problem

LeetCode 200. Given an m x n 2d grid map...

Merge Intervals Problem

LeetCode 56. Given an array of intervals, merge all overlapping...

Diameter of Binary Tree Problem

LeetCode 543. Given a binary tree, compute the diameter of...

Reverse Linked List Problem

LeetCode 206. Reverse a singly linked list.

Reverse Linked List II Problem

LeetCode 92. Reverse a linked list from position m to...

Palindrome Linked List Problem

LeetCode 234. Given a singly linked list, determine if it’s...

Merge K Sorted Lists Problem

LeetCode 23. You are given an array of k linked-lists...

Merge Two Sorted Lists Problem

LeetCode 21. Merge two sorted linked lists and return a...

Median of Two Sorted Arrays Problem

LeetCode 4. Given two sorted arrays nums1 and nums2 of...

Valid Perfect Square Problem

LeetCode 367. Given a positive integer num, write a function...

Sqrt(x) Problem

LeetCode 69. Given a non-negative integer x, compute and return...

Search Insert Position Problem

LeetCode 35. Given a sorted array of distinct integers and...

Stream of Characters Problem

LeetCode 1032. Implement the StreamChecker class as follows. Constructor, initialize...

Maximum XOR of Two Numbers in an Array Problem

LeetCode 421. Given an integer array nums, return the maximum...

Implement Trie (Prefix Tree) Problem

LeetCode 208. Implement a Trie with insert, search, and startsWith...

Camelcase Matching Problem

LeetCode 1023. A query word matches a given pattern if...

Word Search II Problem

LeetCode 212. Given an m x n board of characters...

Two Sum Input Array Is Sorted Problem

LeetCode 167. Given an array of integers nums sorted in...

Subarray Sum Divisible By K Problem

LeetCode 974. Given an array of integers nums and an...

Replace Words Problem

LeetCode 648. Given a dictionary consisting of many roots, and...

Longest Word In Dictionary Problem

LeetCode 720. Given a list of strings words representing an...

Four Sum II Problem

LeetCode 454. Given four lists A, B, C, D of...

Continuous Subarray Sum Problem

LeetCode 523. Given an array of non-negative integers nums and...

Concatenate Words Problem

LeetCode 472. Given a list of words (without duplicates), return...

Two Sum Less Than K Problem

LeetCode 1099. Given an array of integers nums and an...

Subarray Sum Equals K Problem

LeetCode 560. Given an array of integers nums and an...

Subarray Product Less Than K Problem

LeetCode 713. Given an array of positive integers nums and...

Three Sum Problem

LeetCode 15. Given an array of integers nums, return all...

Four Sum Problem

LeetCode 18. Given an array of integers nums and an...

Two Sum Problem

LeetCode 1. Given an array of integers nums and an...

Tag Two Pointer

Palindrome Linked List Problem

LeetCode 234. Given a singly linked list, determine if it’s...

Two Sum Input Array Is Sorted Problem

LeetCode 167. Given an array of integers nums sorted in...

Two Sum Less Than K Problem

LeetCode 1099. Given an array of integers nums and an...

Subarray Product Less Than K Problem

LeetCode 713. Given an array of positive integers nums and...

Three Sum Problem

LeetCode 15. Given an array of integers nums, return all...

Four Sum Problem

LeetCode 18. Given an array of integers nums and an...

Tag Trie

Stream of Characters Problem

LeetCode 1032. Implement the StreamChecker class as follows. Constructor, initialize...

Maximum XOR of Two Numbers in an Array Problem

LeetCode 421. Given an integer array nums, return the maximum...

Implement Trie (Prefix Tree) Problem

LeetCode 208. Implement a Trie with insert, search, and startsWith...

Camelcase Matching Problem

LeetCode 1023. A query word matches a given pattern if...

Word Search II Problem

LeetCode 212. Given an m x n board of characters...

Replace Words Problem

LeetCode 648. Given a dictionary consisting of many roots, and...

Longest Word In Dictionary Problem

LeetCode 720. Given a list of strings words representing an...

Concatenate Words Problem

LeetCode 472. Given a list of words (without duplicates), return...


Number of Islands Problem

LeetCode 200. Given an m x n 2d grid map...

Diameter of Binary Tree Problem

LeetCode 543. Given a binary tree, compute the diameter of...

Longest Word In Dictionary Problem

LeetCode 720. Given a list of strings words representing an...

Concatenate Words Problem

LeetCode 472. Given a list of words (without duplicates), return...

Tag Backtracking

Word Search II Problem

LeetCode 212. Given an m x n board of characters...

Tag Greedy

Maximum XOR of Two Numbers in an Array Problem

LeetCode 421. Given an integer array nums, return the maximum...

Tag Queue

Number of Islands Problem

LeetCode 200. Given an m x n 2d grid map...

Stream of Characters Problem

LeetCode 1032. Implement the StreamChecker class as follows. Constructor, initialize...


Median of Two Sorted Arrays Problem

LeetCode 4. Given two sorted arrays nums1 and nums2 of...

Valid Perfect Square Problem

LeetCode 367. Given a positive integer num, write a function...

Sqrt(x) Problem

LeetCode 69. Given a non-negative integer x, compute and return...

Search Insert Position Problem

LeetCode 35. Given a sorted array of distinct integers and...

Tag C++

Value Categories in C++

Every C++ expression has a type and belongs to a...

Rvalue References in C++: Perfect Forwarding

Perfect forwarding reduces the need for overloaded functions and helps...

Rvalue References in C++: Move Semantics

The rvalue references enable us to distinguish an lvalue from...

References in C++

A reference is an alias of another object. It stores...

Lvalue References in C++

An lvalue reference is another name of an object. An...

Lambda Expressions in C++

A lambda expression is a convenient way of defining an...

Template Specializations in C++

A template specialization is a separate definition in which the...

Implicit Type Conversions in C++

C++ transforms the operands to a common type before performing...

Explicit Type Conversions in C++

An explicit conversion is also called as a cast. There...

Copy Constructors in C++

The constructor that takes a single parameter that is a...

Inline Functions in C++

A function specified as inline is expanded everywhere it is...

Function Pointers in C++

A function pointer is a pointer that denotes a function...

Online Book Reader System Problem

Design the data structures for an online book reader system...

Parking Lot Problem

Design a parking lot using object-oriented principles. We will focus...

Call Center Problem

An object oriented design problem. Imagine you have a call...

Singleton Design Pattern

The singleton design pattern is a type of creational pattern...

Factory Design Pattern

The factory design pattern is a type of creational pattern...

Weak_Ptr in C++

Sometimes an object must store a way to access the...

Friend Class and Function in C++

A friend class can access private and protected members of...

Unique_Ptr in C++

A unique_ptr does not share its pointer. It cannot be...

Smart Pointers in C++

In modern C++ programming, the Standard Library includes smart pointers,...

Shared_Ptr in C++

The shared_ptr type is a smart pointer that is designed...

Templates in C++

A template is a blueprint or formula for creating a...

Polymorphism in C++

Polymorphism means having more than one function with the same...

Interfaces in C++

An interface describes the behavior or capabilities of a C++...

Tag Interface

Interfaces in C++

An interface describes the behavior or capabilities of a C++...

Tag Abstract Class

Interfaces in C++

An interface describes the behavior or capabilities of a C++...


Tag Pure Virtual Function

Polymorphism in C++

Polymorphism means having more than one function with the same...

Interfaces in C++

An interface describes the behavior or capabilities of a C++...

Tag Concrete Class

Interfaces in C++

An interface describes the behavior or capabilities of a C++...

Tag Polymorphism

Polymorphism in C++

Polymorphism means having more than one function with the same...

Tag Overload

Polymorphism in C++

Polymorphism means having more than one function with the same...


Tag Override

Polymorphism in C++

Polymorphism means having more than one function with the same...

Tag Virtual Function

Polymorphism in C++

Polymorphism means having more than one function with the same...

Tag Template

Template Specializations in C++

A template specialization is a separate definition in which the...

Templates in C++

A template is a blueprint or formula for creating a...

Tag Function Template

Templates in C++

A template is a blueprint or formula for creating a...


Tag Class Template

Templates in C++

A template is a blueprint or formula for creating a...

Tag Smart Pointers

Weak_Ptr in C++

Sometimes an object must store a way to access the...

Unique_Ptr in C++

A unique_ptr does not share its pointer. It cannot be...

Smart Pointers in C++

In modern C++ programming, the Standard Library includes smart pointers,...

Shared_Ptr in C++

The shared_ptr type is a smart pointer that is designed...

Tag RAII

Weak_Ptr in C++

Sometimes an object must store a way to access the...

Unique_Ptr in C++

A unique_ptr does not share its pointer. It cannot be...

Smart Pointers in C++

In modern C++ programming, the Standard Library includes smart pointers,...

Shared_Ptr in C++

The shared_ptr type is a smart pointer that is designed...

Tag Shared_Ptr

Smart Pointers in C++

In modern C++ programming, the Standard Library includes smart pointers,...

Shared_Ptr in C++

The shared_ptr type is a smart pointer that is designed...


Tag Raw Pointers

Smart Pointers in C++

In modern C++ programming, the Standard Library includes smart pointers,...

Tag Unique_Ptr

Unique_Ptr in C++

A unique_ptr does not share its pointer. It cannot be...

Smart Pointers in C++

In modern C++ programming, the Standard Library includes smart pointers,...

Tag Weak_Ptr

Weak_Ptr in C++

Sometimes an object must store a way to access the...

Smart Pointers in C++

In modern C++ programming, the Standard Library includes smart pointers,...

Tag Friend Class

Friend Class and Function in C++

A friend class can access private and protected members of...


Tag Friend Function

Friend Class and Function in C++

A friend class can access private and protected members of...

Tag Cyclic Reference

Weak_Ptr in C++

Sometimes an object must store a way to access the...

Tag Weak Reference

Weak_Ptr in C++

Sometimes an object must store a way to access the...

Tag Factory Pattern

Factory Design Pattern

The factory design pattern is a type of creational pattern...


Tag Creational Pattern

Singleton Design Pattern

The singleton design pattern is a type of creational pattern...

Factory Design Pattern

The factory design pattern is a type of creational pattern...

Tag Singleton Pattern

Call Center Problem

An object oriented design problem. Imagine you have a call...

Singleton Design Pattern

The singleton design pattern is a type of creational pattern...

Tag OOD

Online Book Reader System Problem

Design the data structures for an online book reader system...

Parking Lot Problem

Design a parking lot using object-oriented principles. We will focus...

Call Center Problem

An object oriented design problem. Imagine you have a call...

Tag Linked List

Add Two Numbers Problem

LeetCode 2. You are given two non-empty linked lists representing...

Reverse Linked List Problem

LeetCode 206. Reverse a singly linked list.

Reverse Linked List II Problem

LeetCode 92. Reverse a linked list from position m to...

Palindrome Linked List Problem

LeetCode 234. Given a singly linked list, determine if it’s...

Merge K Sorted Lists Problem

LeetCode 23. You are given an array of k linked-lists...

Merge Two Sorted Lists Problem

LeetCode 21. Merge two sorted linked lists and return a...


Tag Priority Queue

Merge K Sorted Lists Problem

LeetCode 23. You are given an array of k linked-lists...

Tag Virtual Memory

Virtual Memory VIII: Page Replacement Policies

How can the OS decide which page(s) to evict from...

Virtual Memory V: TLBs

How can we speed up address translation, and generally avoid...

Virtual Memory IV: Paging

How can we virtualize memory with pages, so as to...

Virtual Memory III: Segmentation

How to support a large address space with (potentially) a...

Virtual Memory II: Address Translation

How can we relocate the process in memory in a...

Virtual Memory I: Overview

Virtual Memory is an abstraction that the Operating System provides...

Tag Function Pointers

Function Pointers in C++

A function pointer is a pointer that denotes a function...

Tag Pointers to Functions

Function Pointers in C++

A function pointer is a pointer that denotes a function...


Tag Inline Functions

Inline Functions in C++

A function specified as inline is expanded everywhere it is...

Tag Process

Process I: The Abstraction

How can the OS provide the illusion of nearly-endless supply...

Tag Copy Constructors

Copy Constructors in C++

The constructor that takes a single parameter that is a...

Tag Tree

Diameter of Binary Tree Problem

LeetCode 543. Given a binary tree, compute the diameter of...


Tag Sliding Window

Tag Sort

Merge Intervals Problem

LeetCode 56. Given an array of intervals, merge all overlapping...

Number of Islands Problem

LeetCode 200. Given an m x n 2d grid map...

Tag Type Conversion

Implicit Type Conversions in C++

C++ transforms the operands to a common type before performing...

Explicit Type Conversions in C++

An explicit conversion is also called as a cast. There...


Tag Cast

Explicit Type Conversions in C++

An explicit conversion is also called as a cast. There...

Tag Template Specialization

Template Specializations in C++

A template specialization is a separate definition in which the...

Tag Partial Specialization

Template Specializations in C++

A template specialization is a separate definition in which the...

Tag Concurrency

Concurrency II: Introduction Cont'd

Another important question is how threads interact when they access...

Concurrency I: Introduction

A thread is an abstraction for a single running process....


Tag Thread

Concurrency II: Introduction Cont'd

Another important question is how threads interact when they access...

Concurrency I: Introduction

A thread is an abstraction for a single running process....

Tag C++ Concepts

C++ Concept List

A growing list of posts under the topic of C++...

Tag Object Oriented Design

Object Oriented Design Topic List

A growing list of posts under the topic of Object...

Tag Operating System

Operating System Topic List

A growing list of posts under the topic of Operating...


Tag Lambda Expression

Lambda Expressions in C++

A lambda expression is a convenient way of defining an...

Tag Reference

Value Categories in C++

Every C++ expression has a type and belongs to a...

Rvalue References in C++: Perfect Forwarding

Perfect forwarding reduces the need for overloaded functions and helps...

Rvalue References in C++: Move Semantics

The rvalue references enable us to distinguish an lvalue from...

References in C++

A reference is an alias of another object. It stores...

Lvalue References in C++

An lvalue reference is another name of an object. An...

Tag Lvalue Reference

Value Categories in C++

Every C++ expression has a type and belongs to a...

Rvalue References in C++: Perfect Forwarding

Perfect forwarding reduces the need for overloaded functions and helps...

Rvalue References in C++: Move Semantics

The rvalue references enable us to distinguish an lvalue from...

References in C++

A reference is an alias of another object. It stores...

Lvalue References in C++

An lvalue reference is another name of an object. An...

Tag Rvalue Reference

Value Categories in C++

Every C++ expression has a type and belongs to a...

Rvalue References in C++: Perfect Forwarding

Perfect forwarding reduces the need for overloaded functions and helps...

Rvalue References in C++: Move Semantics

The rvalue references enable us to distinguish an lvalue from...

References in C++

A reference is an alias of another object. It stores...

Lvalue References in C++

An lvalue reference is another name of an object. An...


Tag LeetCode

LeetCode Database Solution List

A list of LeetCode database problems and solutions.

LeetCode Solution List

A growing list of LeetCode problems and solutions.

Tag MySQL

Rearrange Products Table Problem

LeetCode 1795. Write an SQL query to rearrange the Products...

Find Interview Candidates Problem

LeetCode 1811. Write an SQL query to report the name...

Ad-Free Sessions Problem

LeetCode 1809. Write an SQL query to report all the...

Primary Department For Each Employee Problem

LeetCode 1789. Write an SQL query to report all the...

Grand Slam Titles Problem

LeetCode 1783. Write an SQL query to report the number...

Product's Price For Each Store Problem

LeetCode 1777. Write an SQL query to find the price...

Find The Subtasks That Did Not Execute Problem

LeetCode 1767. Write an SQL query to report the IDs...

Recyclable And Low Fat Products Problem

LeetCode 1757. Write an SQL query to find the ids...

Leetflex Banned Accounts Problem

LeetCode 1747. Write an SQL query to find the account_id...

Find Total Time Spent By Each Employee Problem

LeetCode 1741. Write an SQL query to calculate the total...

The Number Of Employees Which Report To Each Employee Problem

LeetCode 1731. Write an SQL query to report the ids...

Find Followers Count Problem

LeetCode 1729. Write an SQL query that will, for each...

MySQL INNER JOIN Clause

The INNER JOIN keyword selects records that have matching values...

MySQL Aliases

Aliases are nicknames. They give us a shorthand way of...

Count Apples And Oranges Problem

LeetCode 1715. Write an SQL query to count the number...

MySQL OR Operator

The OR operator combines two Boolean expressions and returns true...

MySQL LIMIT Operator

The LIMIT clause is used in the SELECT statement to...

MySQL LIKE Operator

The LIKE operator is used in a WHERE clause to...

MySQL IS NULL Operator

To test whether a value is NULL or not, we...

MySQL IN Clause

The IN operator allows us to determine if a specified...

MySQL BETWEEN Operator

The BETWEEN operator selects values within a given range.

MySQL AND Operator

The AND operator is a logical operator that combines two...

MySQL WHERE Clause

The WHERE clause allows us to choose which rows are...

MySQL DISTINCT Clause

In order to remove duplicate rows, we use the DISTINCT...

Biggest Window Between Visits Problem

LeetCode 1709. Write an SQL query that will, for each...

MySQL ORDER BY Clause

The ORDER BY clause is used to sort the result-set...

MySQL SELECT Statement

The SELECT statement allows us to read data from one...

MySQL Tutorial List

A growing list of MySQL tutorials.

Total Sales Amount By Year Problem

LeetCode 1384. Write an SQL query to report the Total...

Sales By Day Of The Week Problem

LeetCode 1479. Write an SQL query to report how many...

Hopper Company Queries III Problem

LeetCode 1651. Write an SQL query to compute the average_ride_distance...

Get The Second Most Recent Activity Problem

LeetCode 1369. Write an SQL query to show the second...

Find The Quiet Students In All Exams Problem

LeetCode 1412. Write an SQL query to report the students...

Tournament Winners Problem

LeetCode 1194. Write an SQL query to find the winner...

Students Report By Geography Problem

LeetCode 618. A U.S graduate school has students from Asia,...

Report Contiguous Dates Problem

LeetCode 1225. Write an SQL query to generate a report...

Median Employee Salary Problem

LeetCode 569. Write a SQL query to find the median...

Market Analysis II Problem

LeetCode 1159. Write an SQL query to find for each...

Hopper Company Queries I Problem

LeetCode 1635. Write an SQL query to report the following...

Game Play Analysis V Problem

LeetCode 1097. Write an SQL query that reports for each...

User Purchase Platform Problem

LeetCode 1127. Write an SQL query to find the total...

Trips And Users Problem

LeetCode 262. Write a SQL query to find the cancellation...

Number Of Transactions Per Visit Problem

LeetCode 1336. Write an SQL query to find how many...

Human Traffic Of Stadium Problem

LeetCode 601. Write an SQL query to display the records...

Hopper Company Queries II Problem

LeetCode 1645. Write an SQL query to report the percentage...

Find Median Given Frequency Of Numbers Problem

LeetCode 571. Write a query to find the median of...

Find Cumulative Salary Of An Employee Problem

LeetCode 579. Write a SQL to get the cumulative sum...

Department Top Three Salaries Problem

LeetCode 185. Write a SQL query to find employees who...

Average Salary: Departments VS Company Problem

LeetCode 615. Given two tables as below, write a query...

Unpopular Books Problem

LeetCode 1098. Write an SQL query that reports the books...

Second Degree Follower Problem

LeetCode 614. Please write a sql query to get the...

Reported Posts II Problem

LeetCode 1132. Write an SQL query to find the average...

Number Of Calls Between Two Persons Problem

LeetCode 1699. Write an SQL query to report the number...

Nth Highest Salary Problem

LeetCode 177. Write a SQL query to get the nth...

New Users Daily Count Problem

LeetCode 1107. Write an SQL query that reports for every...

Monthly Transactions II Problem

LeetCode 1205. Write an SQL query to find for each...

Get Highest Answer Rate Question Problem

LeetCode 578. Write a sql query to identify the question...

Department Highest Salary Problem

LeetCode 184. Write a SQL query to find employees who...

Article Views II Problem

LeetCode 1149. Write an SQL query to find all the...

Active Users Problem

LeetCode 1454. Write an SQL query to find the id...

Winning Candidate Problem

LeetCode 574. Write a sql to find the name of...

Team Scores In Football Tournament Problem

LeetCode 1212. Write an SQL query that selects the team_id,...

Rank Scores Problem

LeetCode 178. Write a SQL query to rank scores. If...

Product Sales Analysis III Problem

LeetCode 1070. Write an SQL query that selects the product...

Movie Rating Problem

LeetCode 1341. Write the following SQL query to find the...

Investments In 2016 Problem

LeetCode 585. Write a query to print the sum of...

Immediate Food Delivery II Problem

LeetCode 1174. Write an SQL query to find the percentage...

Friend Requests II: Who Has The Most Friends Problem

LeetCode 602. In social network like Facebook or Twitter, people...

Countries You Can Safely Invest In Problem

LeetCode 1501. Write an SQL query to find the countries...

Count Student Number In Departments Problem

LeetCode 580. A university uses 2 data tables, student and...

Bank Account Summary Problem

LeetCode 1555. Our bank records all transactions in the table...

Tree Node Problem

LeetCode 608. Given a table tree, id is identifier of...

The Most Recent Orders For Each Product Problem

LeetCode 1549. Write an SQL query to find the most...

Shortest Distance In A Plane Problem

LeetCode 612. Write a query to find the shortest distance...

Rectangles Area Problem

LeetCode 1459. Write an SQL query to report of all...

Product Price At A Given Date Problem

LeetCode 1164. Write an SQL query to find the prices...

Page Recommendations Problem

LeetCode 1264. Write an SQL query to recommend pages to...

Monthly Transactions I Problem

LeetCode 1193. Write an SQL query to find for each...

Market Analysis I Problem

LeetCode 1158. Write an SQL query to find for each...

Managers With At Least 5 Direct Reports Problem

LeetCode 570. Given the Employee table, write a SQL query...

Find The Missing IDs Problem

LeetCode 1613. Write an SQL query to find the missing...

Exchange Seats Problem

LeetCode 626. Mary is a teacher in a middle school...

Customers Who Bought All Products Problem

LeetCode 1045. Write an SQL query for a report that...

Active Business Problem

LeetCode 1126. Write an SQL query to find all active...

The Most Recent Three Orders Problem

LeetCode 1532. Write an SQL query to find the most...

Restaurant Growth Problem

LeetCode 1321. You are the restaurant owner and you want...

Project Employees III Problem

LeetCode 1077. Write an SQL query that reports the most...

Number Of Trusted Contacts Of A Customer Problem

LeetCode 1364. Write an SQL query to find the following...

NPV Queries Problem

LeetCode 1421. Write an SQL query to find the npv...

Last Person To Fit In The Elevator Problem

LeetCode 1204. Write an SQL query to find the person_name...

Highest Grade For Each Student Problem

LeetCode 1112. Write a SQL query to find the highest...

Evaluate Boolean Expression Problem

LeetCode 1440. Write an SQL query to evaluate the boolean...

Calculate Salaries Problem

LeetCode 1468. Write an SQL query to find the salaries...

Activity Participants Problem

LeetCode 1355. Write an SQL query to find the names...

User Activity For The Past 30 Days II Problem

LeetCode 1142. Write an SQL query to find the average...

The Most Frequently Ordered Products For Each Customer Problem

LeetCode 1596. Write an SQL query to find the most...

Running Total For Different Genders Problem

LeetCode 1308. Write an SQL query to find the total...

Friendly Movies Streamed Last Month Problem

LeetCode 1495. Write an SQL query to report the distinct...

Friend Requests I: Overall Acceptance Rate Problem

LeetCode 597. Write an SQL query to find the overall...

Find The Start And End Number Of Continuous Ranges Problem

LeetCode 1285. Write an SQL query to find the start...

Customers Who Bought Products A And B But Not C Problem

LeetCode 1398. Write an SQL query to report the customer_id...

Classes More Than 5 Students Problem

LeetCode 596. Please list out all classes which have more...

Capital Gain/Loss Problem

LeetCode 1393. Write an SQL query to report the Capital...

Biggest Single Number Problem

LeetCode 619. Table my_numbers contains many numbers in column num...

Apples & Oranges Problem

LeetCode 1445. Write an SQL query to report the difference...

All People Report To The Given Manager Problem

LeetCode 1270. Write an SQL query to find employee_id of...

Weather Type In Each Country Problem

LeetCode 1294. Write an SQL query to find the type...

User Activity For The Past 30 Days I Problem

LeetCode 1141. Write an SQL query to find the daily...

Triangle Judgement Problem

LeetCode 610. A pupil Tim gets homework to identify whether...

Students And Examinations Problem

LeetCode 1280. Write an SQL query to find the number...