1 2 3 4 5 ··· 10 下一页
摘要: 对于一个数组 arr[1...n],Fenwick Tree 可以支持两种操作: update(i, delta):将 arr[i] += delta query(i):返回前缀和 arr[1] + arr[2] + ... + arr[i] 它的时间复杂度为: 构建:O(n) 查询:O(log n 阅读全文
posted @ 2025-07-21 04:06 xiaoyongyong 阅读(9) 评论(0) 推荐(0)
摘要: 3447. Assign Elements to Groups with Constraints Solved Medium Topics Companies Hint You are given an integer array groups, where groups[i] represents 阅读全文
posted @ 2025-02-16 08:15 xiaoyongyong 阅读(13) 评论(0) 推荐(0)
摘要: 1878. Get Biggest Three Rhombus Sums in a Grid You are given an m x n integer matrix grid​​​. A rhombus sum is the sum of the elements that form the b 阅读全文
posted @ 2024-11-25 01:24 xiaoyongyong 阅读(44) 评论(0) 推荐(0)
摘要: 126. Word Ladder II A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 - 阅读全文
posted @ 2024-11-24 05:10 xiaoyongyong 阅读(31) 评论(0) 推荐(0)
摘要: 使用着色法来判定一个图是否为二分图,或者是否包含奇环(包含奇环的话就不是二分图) 785. Is Graph Bipartite? There is an undirected graph with n nodes, where each node is numbered between 0 and 阅读全文
posted @ 2024-11-23 08:52 xiaoyongyong 阅读(41) 评论(0) 推荐(0)
摘要: 564. Find the Closest Palindrome Given a string n representing an integer, return the closest integer (not including itself), which is a palindrome. I 阅读全文
posted @ 2024-11-22 08:39 xiaoyongyong 阅读(44) 评论(0) 推荐(0)
摘要: 296. Best Meeting Point Given an m x n binary grid grid where each 1 marks the home of one friend, return the minimal total travel distance. The total 阅读全文
posted @ 2024-11-18 07:42 xiaoyongyong 阅读(72) 评论(0) 推荐(0)
摘要: 1526. Minimum Number of Increments on Subarrays to Form a Target Array You are given an integer array target. You have an integer array initial of the 阅读全文
posted @ 2024-07-22 09:24 xiaoyongyong 阅读(27) 评论(0) 推荐(0)
摘要: 3186. Maximum Total Damage With Spell Casting A magician has various spells. You are given an array power, where each element represents the damage of 阅读全文
posted @ 2024-06-17 01:13 xiaoyongyong 阅读(92) 评论(0) 推荐(0)
摘要: 给定一个数组,没有重复元素,要将其排列为一小一大一小一大, 比如: [8,6,7,3,4,5] 结果是: [6,8,3,7,4,5] [1,2,3,4,5] 结果是: [1,3,2,5,4] one pass void sort(int[] arr) { for(int i = 0; i < arr 阅读全文
posted @ 2024-03-31 00:28 xiaoyongyong 阅读(18) 评论(0) 推荐(0)
1 2 3 4 5 ··· 10 下一页