摘要:给定一个矩阵 A, 返回 A 的转置矩阵。 矩阵的转置是指将矩阵的主对角线翻转,交换矩阵的行索引与列索引。 示例 1: 示例 2: 提示:
阅读全文
摘要:在柠檬水摊上,每一杯柠檬水的售价为 5 美元。 顾客排队购买你的产品,(按账单 bills 支付的顺序)一次购买一杯。 每位顾客只买一杯柠檬水,然后向你付 5 美元、10 美元或 20 美元。你必须给每个顾客正确找零,也就是说净交易是每位顾客向你支付 5 美元。 注意,一开始你手头没有任何零钱。 如
阅读全文
摘要:https://leetcode-cn.com/problems/sort-array-by-parity/description/ * * algorithms * Easy (69.43%) * Total Accepted: 12.3K * Total Submissions: 17.7K * Testcase Example: '[3,1,2,4]' * * 给...
阅读全文
摘要:import java.util.List; /* * @lc app=leetcode.cn id=985 lang=java * * [985] 令牌放置 * * https://leetcode-cn.com/problems/sum-of-even-numbers-after-queries/description/ * * algorithms * Easy (67....
阅读全文
摘要:/* * @lc app=leetcode.cn id=191 lang=java * * [191] 位1的个数 * * https://leetcode-cn.com/problems/number-of-1-bits/description/ * * algorithms * Easy (47.11%) * Total Accepted: 13.8K * Tota...
阅读全文
摘要:/* * @lc app=leetcode.cn id=637 lang=java * * [637] 二叉树的层平均值 * * https://leetcode-cn.com/problems/average-of-levels-in-binary-tree/description/ * * algorithms * Easy (56.65%) * Total Accepte...
阅读全文
摘要:/* * @lc app=leetcode.cn id=633 lang=java * * [633] 平方数之和 * * https://leetcode-cn.com/problems/sum-of-square-numbers/description/ * * algorithms * Easy (29.35%) * Total Accepted: 4K * To...
阅读全文
摘要:/* * @lc app=leetcode.cn id=551 lang=java * * [551] 学生出勤记录 I * * https://leetcode-cn.com/problems/student-attendance-record-i/description/ * * algorithms * Easy (46.31%) * Total Accepted: ...
阅读全文
摘要:斐波那契数,通常用 F(n) 表示,形成的序列称为斐波那契数列。该数列由 0 和 1 开始,后面的每一项数字都是前面两项数字的和。也就是: 给定 N,计算 F(N)。 示例 1: 示例 2: 示例 3: 提示: 0 ≤ N ≤ 30 class Solution { public int fib(i
阅读全文
摘要:给定两个数组,编写一个函数来计算它们的交集。 示例 1: 示例 2: 说明: 输出结果中的每个元素一定是唯一的。 我们可以不考虑输出结果的顺序。 class Solution { public int[] intersection(int[] nums1, int[] nums2) { Set<In
阅读全文
摘要:编写一个函数,以字符串作为输入,反转该字符串中的元音字母。 示例 1: 示例 2: 说明:元音字母不包含字母"y"。
阅读全文
摘要:编写一个函数,其作用是将输入的字符串反转过来。输入字符串以字符数组 char[] 的形式给出。 不要给另外的数组分配额外的空间,你必须原地修改输入数组、使用 O(1) 的额外空间解决这一问题。 你可以假设数组中的所有字符都是 ASCII 码表中的可打印字符。 示例 1: 示例 2:
阅读全文