当前位置:网站首页>剑指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;
}
}
边栏推荐
- MySQL(更新中)
- MySQL (updating)
- sql语句-如何以一个表中的数据为条件据查询另一个表中的数据
- Duplicate entry ‘XXX‘ for key ‘XXX.PRIMARY‘解决方案。
- SQL injection of DVWA
- Centos7 install mysql5.7 steps (graphical version)
- Three oj questions on leetcode
- Mysql——字符串函数
- Unity mobile game performance optimization series: performance tuning for the CPU side
- Kubernetes加入集群的TOKEN值过期
猜你喜欢

The interviewer asked me TCP three handshake and four wave, I really

Linux系统安装mysql(rpm方式安装)

centos7安装mysql5.7步骤(图解版)

Interviewer: If the order is not paid within 30 minutes, it will be automatically canceled. How to do this?

Unity Framework Design Series: How Unity Designs Network Frameworks

Unity mobile game performance optimization series: performance tuning for the CPU side

Typec手机有线网卡网线转网口转接口快充方案

SQL行列转换

MySQL事务隔离级别详解

CentOS7 - yum install mysql
随机推荐
基于web3.0使用钱包Metamask的三方登陆
MySQL_关于JSON数据的查询
Multiple table query of sql statement
Duplicate entry 'XXX' for key 'XXX.PRIMARY' solution.
账号或密码多次输入错误,进行账号封禁
面试官:生成订单30分钟未支付,则自动取消,该怎么实现?
质量小议12 -- 以测代评
C语言教程(三)-if和循环
What are the advantages and disadvantages of Unity shader forge and the built-in shader graph?
sql语句-如何以一个表中的数据为条件据查询另一个表中的数据
Pytorch教程Introduction中的神经网络实现示例
CentOS7 安装MySQL 图文详细教程
PCL calculates the point cloud coordinate maximum and its index
MySQL (updating)
基于flask的三方登陆的流程
Interviewer: If the order is not paid within 30 minutes, it will be automatically canceled. How to do this?
MySQL-Explain详解
Tapdata 与 Apache Doris 完成兼容性互认证,共建新一代数据架构
MySQL常见面试题汇总(建议收藏!!!)
[Introduction to MySQL 8 to Mastery] Basics - silent installation of MySQL on Linux system, cross-version upgrade