Recent Posts
-
Leetcode SQL: 570 Managers with at Least 5 Direct Reports
•
SELECT e.name FROM Employee e JOIN ( SELECT managerId FROM Employee WHERE managerId IS NOT NULL GROUP BY managerId HAVING COUNT(*) >= 5 ) AS ManagersWithReports ON e.id = ManagersWithReports.managerId; Explanation: Subquery – Find Managers with at Least 5 Reports: We first create a subquery to count how many direct…
-
LeetCode: 617 Merge Two Binary Trees
•
You are given two binary trees root1 and root2. Imagine that when you put one tree over the other, some nodes of the two trees overlap while others do not. You need to merge the two trees into a new binary tree. The merge rule is that if two nodes…
-
LeetCode: 1299 Replace Elements with Greatest Element on Right Side
•
Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1. After doing so, return the array. Example Input: arr = [17,18,5,4,6,1] Output: [18,6,6,6,1,-1] Explanation: – Index 0 → The greatest element to the…