xinyu04

导航

2022年7月29日 #

LeetCode 204 Count Primes 欧拉(素数)筛

摘要: Given an integer $n$, return the number of prime numbers that are strictly less than $n$. Solution 统计小于 $n$ 的素数个数。这里用欧拉筛来筛素数,$is_prime$ 用来记录该数是否为素数,$p 阅读全文

posted @ 2022-07-29 19:23 Blackzxy 阅读(22) 评论(0) 推荐(0) 编辑

LeetCode 162 Find Peak Element 二分

摘要: A peak element is an element that is strictly greater than its neighbors. Given a $0$-indexed integer array nums, find a peak element, and return its 阅读全文

posted @ 2022-07-29 18:49 Blackzxy 阅读(14) 评论(0) 推荐(0) 编辑

LeetCode 153 Find Minimum in Rotated Sorted Array 二分

摘要: Suppose an array of length $n$ sorted in ascending order is rotated between $1$ and $n$ times. For example, the array nums = [0,1,2,4,5,6,7] might bec 阅读全文

posted @ 2022-07-29 17:05 Blackzxy 阅读(8) 评论(0) 推荐(0) 编辑

LeetCode 108 Convert Sorted Array to Binary Search Tree DFS

摘要: Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree. A height-balanced bi 阅读全文

posted @ 2022-07-29 05:59 Blackzxy 阅读(11) 评论(0) 推荐(0) 编辑

LeetCode 74 Search a 2D Matrix 二分

摘要: Write an efficient algorithm that searches for a value target in an m x n integer matrix matrix. This matrix has the following properties: Integers in 阅读全文

posted @ 2022-07-29 02:10 Blackzxy 阅读(8) 评论(0) 推荐(0) 编辑