• Algorithms 101: Mastering Tree Algorithms

    Mastering Tree Algorithms: A General Strategy Guide Tree data structures are fundamental in computer science and appear frequently in algorithmic problems. Understanding how to approach tree-related algorithm issues is essential for any developer aiming to excel in technical interviews or enhance their problem-solving skills. 树形数据结构是计算机科学中的基础结构,经常出现在算法问题中。理解如何解决与树相关的算法问题对于任何想要在技术面试中脱颖而出或提高问题解决能力的开发者来说都是至关重要的。 Table of Contents Understanding Tree…

  • Security 101: Authentication in REST APIs

    A Comprehensive Guide to Authentication in REST APIs (With Node.js and Python Examples) Introduction Authentication in REST APIs is a critical layer that ensures only authorized users or systems can access the data and functionalities. Choosing the right authentication method is essential, as it directly impacts the security and user…

  • LeetCode: 235 Lowest Common Ancestor of a Binary Search Tree

    Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node…

  • GraphQL 101: A Step-by-Step Guide to GraphQL

    A Step-by-Step Guide to GraphQL Introduction What is GraphQL? GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. Developed internally by Facebook in 2012 and released publicly in 2015, GraphQL provides a more efficient, powerful, and flexible alternative to REST. Why…

  • LeetCode: 7 Reverse Integer

    Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-2³¹, 2³¹ – 1], then return 0. 给定一个有符号的 32 位整数 x,返回将 x 的数字部分反转后的结果。如果反转后的整数超出了 32 位有符号整数的范围 [-2³¹, 2³¹ – 1],则返回 0。 Example Input: x = 123 Output: 321 Input:…

  • 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…

  • LeetCode: 234 Palindrome Linked List

    Given the head of a singly linked list, return true if it is a palindrome. Example Input: head = [1,2,2,1] Output: true Input: head = [1,2] Output: false 问题 给定单链表的头节点 head,如果它是回文链表,则返回 true。 例子 输入: head = [1,2,2,1] 输出: true 输入: head = [1,2] 输出: false Solution Approach: Two Pointers (Fast…

  • Leetcode SQL: 1661. Average Time of Process per Machine

    1661. Average Time of Process per Machine SQL Code: SELECT machine_id, ROUND(AVG(end_time – start_time), 3) AS processing_time FROM ( SELECT machine_id, process_id, MAX(CASE WHEN activity_type = 'end' THEN timestamp END) AS end_time, MAX(CASE WHEN activity_type = 'start' THEN timestamp END) AS start_time FROM Activity GROUP BY machine_id, process_id ) AS…