当前位置:网站首页>剑指offer基础版--- 第23天
剑指offer基础版--- 第23天
2022-07-31 05:09:00 【米兰的小红黑】

class Solution {
public int majorityElement(int[] nums) {
Arrays.sort(nums);
return nums[nums.length / 2];
}
}

class Solution {
public int[] constructArr(int[] a) {
int len = a.length;
if(len == 0) return new int[0];
int[] b = new int[len];
b[0] = 1;
int tmp = 1;
for(int i = 1; i < len; i++) {
b[i] = b[i - 1] * a[i - 1];
}
for(int i = len - 2; i >= 0; i--) {
tmp *= a[i + 1];
b[i] *= tmp;
}
return b;
}
}
边栏推荐
- 再见了繁琐的Excel,掌握数据分析处理技术就靠它了
- Workflow番外篇
- Shell重油常压塔模拟仿真与控制
- STM32——DMA
- 1. Get data - requests.get()
- 【一起学Rust】Rust学习前准备——注释和格式化输出
- About the problems encountered by Xiaobai installing nodejs (npm WARN config global `--global`, `--local` are deprecated. Use `--location=glob)
- Duplicate entry ‘XXX‘ for key ‘XXX.PRIMARY‘解决方案。
- Flink sink redis 写入Redis
- MySQL(更新中)
猜你喜欢

110 MySQL interview questions and answers (continuously updated)

Mysql——字符串函数

Redis Advanced - Cache Issues: Consistency, Penetration, Penetration, Avalanche, Pollution, etc.

关于小白安装nodejs遇到的问题(npm WARN config global `--global`, `--local` are deprecated. Use `--location=glob)

About the problems encountered by Xiaobai installing nodejs (npm WARN config global `--global`, `--local` are deprecated. Use `--location=glob)

matlab abel变换图片处理

工作流编排引擎-Temporal

【LeetCode-SQL每日一练】——2. 第二高的薪水

【MySQL8入门到精通】基础篇- Linux系统静默安装MySQL,跨版本升级

Apache DButils使用注意事项--with modifiers “public“
随机推荐
MYSQL下载及安装完整教程
12 reasons for MySQL slow query
Mysql application cannot find my.ini file after installation
1. Get data - requests.get()
Flink sink redis 写入Redis
TOGAF之架构标准规范(一)
Temporal对比Cadence
Interviewer: If the order is not paid within 30 minutes, it will be automatically canceled. How to do this?
C语言的文件操作(一)
SQL statement to range query time field
[Detailed explanation of ORACLE Explain]
Information System Project Manager Core Test Site (55) Configuration Manager (CMO) Work
mysql使用on duplicate key update批量更新数据
MySQL-Explain详解
MySQL-如何分库分表?一看就懂
【一起学Rust】Rust的Hello Rust详细解析
Why use Flink and how to get started with Flink?
mysql 的简单运用命令
MySQL事务隔离级别详解
Sql解析转换之JSqlParse完整介绍