当前位置:网站首页>剑指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;
}
}
边栏推荐
- Duplicate entry 'XXX' for key 'XXX.PRIMARY' solution.
- MySQL transaction isolation level, rounding
- Minio上传文件ssl证书不受信任
- Flink sink ES 写入 ES(带密码)
- 分布式事务——分布式事务简介、分布式事务框架 Seata(AT模式、Tcc模式、Tcc Vs AT)、分布式事务—MQ
- 目标检测学习笔记
- Workflow番外篇
- Distributed transaction processing solution big PK!
- 基于web3.0使用钱包Metamask的三方登陆
- centos7安装mysql5.7步骤(图解版)
猜你喜欢

Anaconda配置环境指令

Mysql application cannot find my.ini file after installation

mysql uses on duplicate key update to update data in batches

工作流编排引擎-Temporal

面试官竟然问我怎么分库分表?幸亏我总结了一套八股文

CentOS7 install MySQL graphic detailed tutorial

基于flask的三方登陆的流程

Three oj questions on leetcode

110道 MySQL面试题及答案 (持续更新)

A complete introduction to JSqlParse of Sql parsing and conversion
随机推荐
Shell重油常压塔模拟仿真与控制
DVWA之SQL注入
【一起学Rust】Rust的Hello Rust详细解析
C语言教程(三)-if和循环
Flask 的初识
基于web3.0使用钱包Metamask的三方登陆
账号或密码多次输入错误,进行账号封禁
Flink sink ES 写入 ES(带密码)
Minio upload file ssl certificate is not trusted
MYSQL一站式学习,看完即学完
【MySQL8入门到精通】基础篇- Linux系统静默安装MySQL,跨版本升级
MySQL8.0安装教程,在Linux环境安装MySQL8.0教程,最新教程 超详细
Kubernetes加入集群的TOKEN值过期
基于flask的三方登陆的流程
DVWA安装教程(懂你的不懂·详细)
MySQL8--Windows下使用压缩包安装的方法
torch.normal函数用法
Linux系统安装mysql(rpm方式安装)
C语言教程(二)-printf及c自带的数据类型
Interview Redis High Reliability | Master-Slave Mode, Sentinel Mode, Cluster Cluster Mode