技术文章

这里是Hogan.B Lab 所有技术文章的入口,涵盖系统设计、资料结构与演算法、前端工程与资料库基础。每一篇都尽量把「为什么要这样做」讲清楚,而不只是贴程式码。如果你是自学或准备面试,建议从下面的系列文章开始,一条线读完会比零散跳着看有用得多。

Longest Common Subsequence 解题教学示意图|LeetCode 1143

Longest Common Subsequence 解题教学:3 种解法完整比较|LeetCode 1143 Best Practice

Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.

A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.

For example, “ace” is a subsequence of “abcde”.
A common subsequence of two strings is a subsequence that is common to both strings.

Longest Common Subsequence 解题教学:3 种解法完整比较|LeetCode 1143 Best Practice 阅读更多 ”

Leetcode, 技术文章, , ,
Climbing Stairs 解题教学示意图|LeetCode 70

Climbing Stairs 解题教学:3 种解法完整比较|LeetCode 70 Best Practice

You are climbing a staircase. It takes n steps to reach the top.

Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

Climbing Stairs 解题教学:3 种解法完整比较|LeetCode 70 Best Practice 阅读更多 ”

Leetcode, 技术文章, , ,
Counting Bits 解题教学示意图|LeetCode 338

Counting Bits 解题教学:3 种解法完整比较|LeetCode 338 Best Practice

Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation of i.

Counting Bits 解题教学:3 种解法完整比较|LeetCode 338 Best Practice 阅读更多 ”

Leetcode, 技术文章, , ,
Number of 1 Bits 解题教学示意图|LeetCode 191

Number of 1 Bits 解题教学:3 种解法完整比较|LeetCode 191 Best Practice

Write a function that takes the binary representation of an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).

Note:

Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned.
In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 3, the input represents the signed integer. -3.

Number of 1 Bits 解题教学:3 种解法完整比较|LeetCode 191 Best Practice 阅读更多 ”

技术文章, ,
Maximum Product Subarray 解题教学示意图|LeetCode 152

Maximum Product Subarray 解题教学:3 种解法完整比较|LeetCode 152 Best Practice

Given an integer array nums, find a subarray that has the largest product, and return the product.

The test cases are generated so that the answer will fit in a 32-bitinteger.

Maximum Product Subarray 解题教学:3 种解法完整比较|LeetCode 152 Best Practice 阅读更多 ”

Leetcode, 技术文章, , , ,
Container With Most Water 解题教学示意图|LeetCode 11

Container With Most Water 解题教学:3 种解法完整比较|LeetCode 11 Best Practice

You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).

Find two lines that together with the x-axis form a container, such that the container contains the most water.

Return the maximum amount of water a container can store.

Notice that you may not slant the container.

Container With Most Water 解题教学:3 种解法完整比较|LeetCode 11 Best Practice 阅读更多 ”

Leetcode, 技术文章, , ,