Author: admin

  • LeetCode: 35 Search Insert Position

    Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with O(log n) runtime complexity. Example Input: nums = [1,3,5,6], target…

  • LeetCode: 203 Remove Linked List Elements

    Given the head of a linked list and an integer val, remove all the nodes of the linked list that have Node.val == val, and return the new head. Example Input: head = [1,2,6,3,4,5,6], val = 6 Output: [1,2,3,4,5] Explanation: We remove all the nodes with the value 6. 问题…

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