Author: admin

  • LeetCode: 42 Trapping Rain Water

    LeetCode 42: Trapping Rain Water https://leetcode.com/problems/trapping-rain-water/ Problem Description: Given a non-negative integer array height, where each element represents the height of a bar, calculate how much water can be trapped between these bars after it rains. Example: Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] Output: 6 In this example, the total amount of…

  • Python 101: `None == None` vs `None is None`

    Python: None == None vs None is None – What’s the Difference? In Python, None is a special constant that represents the absence of a value or a null value. It’s an object, and like any object in Python, it can be compared using == (equality) or is (identity). At…

  • Python 101: Python’s `min()` Function with Strings

    Understanding Python’s min() Function with Strings: A Deep Dive Python’s min() function is a powerful tool that returns the smallest item from an iterable, such as a list. When applied to strings, it compares each element based on lexicographical (alphabetical) order. The function evaluates strings character by character using their…

  • LeetCode: 981 Binary Search in `Time Based Key-Value Store`

    LeetCode 981: Time Based Key-Value Store Explanation of Binary Search in Time Based Key-Value Store If we are not allowed to use bisect.bisect_right(values, (timestamp, chr(127))), we can manually implement binary search to achieve the same result. Below is a solution that uses a custom binary search to find the closest…

  • Python 101: `defaultdict(int)` vs `defaultdict(list)`

    Let’s compare defaultdict(int) and defaultdict(list) by using examples that demonstrate their differences and appropriate use cases. 1. defaultdict(int) – Used for Counting Occurrences: When you use defaultdict(int), it initializes missing keys with 0 (the default for int). This is commonly used when you need to count occurrences of elements. Example…

  • Security 101: Zero-Day Vulnerabilities

    Understanding Zero-Day Vulnerabilities: The Hidden Threat to Cybersecurity In the ever-evolving landscape of cybersecurity, zero-day vulnerabilities stand out as one of the most dangerous threats. These security flaws are particularly alarming because they can be exploited before the affected software vendor or security community even knows they exist. For organizations,…

  • LeetCode: 223 Rectangle Area

    LeetCode 223: Rectangle Area https://leetcode.com/problems/rectangle-area/description/ Problem Description: In a 2D plane, given two rectangles defined by their bottom-left and top-right corners, calculate the total area covered by the two rectangles (excluding any overlapping area). You are given the coordinates of two rectangles: (A, B) represents the bottom-left corner of the…

  • System Design 101: Understanding the Differences Between Paging and Segmentation in Memory Management

    Understanding the Differences Between Paging and Segmentation in Memory Management In the realm of operating systems, memory management plays a crucial role in ensuring efficient execution of processes. Two of the most common techniques used for managing memory are Paging and Segmentation. While both are designed to allocate memory and…

  • Python 101: `bisect.bisect_right` function

    The bisect.bisect_right function is part of Python’s bisect module. It is used to find the position where an element should be inserted into a sorted sequence, and it inserts the element from the right side. Explanation bisect_right(a, x): Finds the position where element x should be inserted in the sorted…

  • LeetCode: 776 Split BST

    LeetCode 776: Split BST https://leetcode.com/problems/split-bst/description/ Problem Description Given a Binary Search Tree (BST) and a value V, split the tree into two subtrees. One subtree should contain all nodes with values less than or equal to V, and the other subtree should contain all nodes with values greater than V.…