Wonderhows
  • Home
  • PHP
  • JS
  • Mysql
  • GIT
  • AI
  • Other

Leetcode 169. 多数元素

169. 多数元素 - 力扣(LeetCode) (leetcode-cn.com)

 

 

思路 1:

1. 先对所有元素进行排序

2. 返回位于数组最中间的元素

func majorityElement(nums []int) int { 	lenth:=len(nums) 	sort.Ints(nums) 	return nums[lenth/2] } 

  

  • Other
« Previous

WordPress删除文章同时同时删除缩略图及图片附件的方法

Next »

自制YUM源远程仓库

comments powered by Disqus

Recent Posts

  • 双端队列(搬运)
  • 队列(搬运)
  • 《暗时间》--阅读方法
  • [LeetCode]818. Race Car|BFS & DP附图详解(JavaScript版)
  • mysql:lost connection to MYSQL during query
  • Caddy 反向代理 Portainer
  • Docker-compose 一键搭建 Discourse 论坛
  • Win 11 添加并使用 DOH
  • F5查看光模块类型及信息
  • 源代码管理工具Github

Tags

AI AI Face App AI Image Upscaler App AI Music Generators AI 美颜 AI 音乐生成 git Image Upscaler js nestjs Other PHP 字符串 错误处理
© 2022 Wonderhows.