Tag: Algorithms
-
Algorithms 101: Practical Applications of Bitwise Operations
•
位操作的实际应用 Introduction 介绍 Bitwise operations play a critical role in programming, especially when dealing with tasks that require high performance and precise control over data at the binary level. These operations work directly on the binary representations of data, making them extremely efficient and powerful tools in various programming scenarios.…
-
LeetCode: 704 Binary Search
•
Given a sorted (in ascending order) integer array nums of n elements and a target value target, write a function to search target in nums. If target exists, then return its index, otherwise, return -1. Example: Input: nums = [-1, 0, 3, 5, 9, 12], target = 9 Output: 4…
-
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",…
-
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…
-
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…
-
Algorithms 101: DFS and BFS
•
Depth-First Search (DFS) and Breadth-First Search (BFS) are two common traversal methods for trees and graphs Tree Traversal Depth-First Search (DFS) is an algorithm that traverses the nodes of a tree by searching the branches as deeply as possible. It traverses the nodes of the tree along its depth, exploring…
-
Beginner’s Guide to Algorithms & Data Structures
•
Table of Contents Introduction What are Algorithms? What are Data Structures? Importance of Algorithms and Data Structures Getting Started with Programming Basic Programming Concepts Choosing a Programming Language Writing Your First Program Fundamental Data Structures Arrays Definition and Usage Basic Operations (Access, Insert, Delete) Time and Space Complexity Linked Lists…