Author: admin

  • LeetCode: 217 Contains Duplicate

    Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. Example: Input: nums = [1,2,3,1] Output: true Input: nums = [1,2,3,4] Output: false Input: nums = [1,1,1,3,3,4,3,2,4,2] Output: true 问题 给定一个整数数组 nums,如果任何值在数组中至少出现两次,返回 true;如果数组中的每个元素都是唯一的,返回 false。 解决方案…

  • LeetCode: 1 Two Sum

    Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any…

  • LeetCode: 1071 Greatest Common Divisor of Strings

    For two strings s1 and s2, we say "s1 divides s2" if and only if s2 is formed by concatenating one or more copies of s1. Given two strings str1 and str2, return the largest string x such that x divides both str1 and str2. Example: Input: str1 = "ABCABC",…

  • LeetCode: 1768 Merge Strings Alternately

    You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string. Example: Input: word1 = "abc", word2 = "pqr" Output: "apbqcr" Input:…

  • Algorithms 101: Comprehensive Guide to Binary Tree Traversals

    Binary tree traversals are fundamental techniques in computer science for exploring and manipulating tree data structures. They are crucial for depth-first search (DFS) algorithms, allowing various operations such as searching, sorting, and structuring data in binary trees. 介绍:二叉树遍历是计算机科学中探索和操作树数据结构的基本技术。它们对于深度优先搜索(DFS)算法至关重要,允许在二叉树中进行搜索、排序和数据结构化等各种操作。 Understanding Binary Tree Traversals: 理解二叉树遍历: Definition: Binary tree traversals involve visiting each…

  • Python 101: `if not root:` vs `if root is None:`

    In Python, both if not root: and if root is None: are used to check if a variable is None, but they have subtle differences in their behavior and use cases: if not root: Behavior: This condition checks if root is "falsy." In Python, values like None, 0, False, empty…

  • LeetCode: The Difference between LeetCode 104 and LeetCode 124

    Problem Statement: 104 Maximum Depth of Binary Tree 104 Maximum Depth of Binary Tree: Given the root of a binary tree, return its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 问题陈述: 104 二叉树的最大深度…

  • LeetCode: 104 Maximum Depth of Binary Tree

    Problem Statement Given the root of a binary tree, return its maximum depth. A binary tree’s maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Example: Input: root = [3,9,20,null,null,15,7] Output: 3 问题 给定一个二叉树的根节点,返回其最大深度。 二叉树的最大深度是从根节点到最远叶节点的最长路径上的节点数量。 示例: 输入: root…

  • 50 Steps to Becoming a Top Software Engineer

    50 Steps to Becoming a Top Software Engineer

    50 Steps to Becoming a Top Software Engineer 成为一名顶尖软件工程师的50个步骤 Understand the Basics of Computer Science 理解计算机科学基础 Example: Study fundamental concepts such as algorithms, data structures, and computational theory. 例子:学习基本概念,如算法、数据结构和计算理论。 Learn a Programming Language (Python, Java, C++) 学习一种编程语言(Python, Java, C++) Example: Start with Python for its simplicity and readability. 例子:从Python开始,因为它简单且易读。 Study…

  • System Design: Domain-Driven Design

    System Design: Domain-Driven Design

    Introduction to Domain-Driven Design 领域驱动设计简介 Creating software for intricate domains is a demanding endeavor. 为复杂领域开发软件是一项艰巨的任务。 As the intricacy of the problem domain increases, it becomes more challenging to design software that accurately reflects business concepts, rules, and processes. 随着问题领域复杂性的增加,设计能够准确反映业务概念、规则和流程的软件变得更加具有挑战性。 Poorly constructed software can quickly devolve into an unmanageable jumble of…