当前位置:网站首页>测试岗位面试常见算法题集锦
测试岗位面试常见算法题集锦
2022-07-19 13:54:00 【我是小明ya】
def pra_01(self):
# 给你一个整数数组nums ,其中元素已经按升序排列,请你将其转换为一棵高度平衡
# 二叉搜索树。高度平衡
# 二叉树是一棵满足「每个节点的左右两个子树的高度差的绝对值不超过1 」的二叉树。
nums = [1,2,3,4,5]
def pra_02(self):
# 给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写
str = 'Aabffbaa'
if str.lower() == str[::-1].lower():print('yes')
def pra_03(self):
# 给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。
# 说明:你的算法应该具有线性时间复杂度。你可以不使用额外空间来实现吗?
nums = [1,2,2,3,3]
result = 0
for num in nums:result = result ^ num
print(result)
def pra_04(self):
# 给定一串字符串,找出出现次数最多的字符
s = 'abca'
l = list(s)
max = 0
result = ''
for i in range(0,len(l)-1):
sum = 0
print(l[i],l[i+1])
for j in range(i+1,len(l)-2):
if l[i] == l[j]:sum=sum+1
if sum>max: max = sum;result = l[i]
print(max,result)
边栏推荐
- Introduction to GC mechanism
- 【OpenCV 例程200篇】237. 基于主成分提取的方向校正(OpenCV)
- Originally, MAE proposed by he Kaiming is still a kind of data enhancement! Based on MAE, Shanghai Communications & Huawei proposes masking reconstruction data enhancement, which is better than cutmix
- 柱塞泵ParKer PVP23363R26A121
- 统计信息简介
- Understand chisel language thoroughly 20. Chisel combinational circuit (II) -- implementation of chisel encoder and decoder
- 吃透Chisel语言.17.Chisel模块详解(四)——用函数实现轻量级模块
- Plunger pump Parker pvp23363r26a121
- PHP step hole array access
- Embedded software architecture Division
猜你喜欢
Don't understand MySQL database? Alibaba P8 architects will show you MySQL and Optimization in simple terms
矽穀課堂第十三課-直播管理模塊
[introduction series of redis] get to know redis and the installation of redis
使用 GPU 发现人脑连接,大规模 GPU 实现了 100 倍的加速
区间合并[关键问题+解决方案]
CTFHub 技能树web
MySQL数据库优化的这几种方式你都知道吗?
MySQL eight part essay, preparing for the golden nine silver ten
备赛笔记:Opencv学习:颜色识别
Huggingface | technology behind bloom model training
随机推荐
吃透Chisel语言.19.Chisel组合电路(一)——Chisel组合电路与Chisel条件语句
一文了解 Nebula Graph 上的 Spark 项目
模糊综合评价法
【OpenCV】记录cv2.VideoCapture的一个坑
微信小程序实现选项卡的代码怎么写
2022最新String面试题及答案
Do you still have certificates to participate in the open source community?
The first small sample detection benchmark and weak feature enhancement network under X-ray, and the new research of Beihang and iFLYTEK was selected into ACM mm 2022
PHP 匿名函数使用
柱塞泵ParKer PVP23363R26A121
Obtain epidemic information and data
硅谷课堂第十二课-公众号点播课程和直播管理模块
如何使用 SAP Intelligent Robotic Process Automation 自动操作 Excel
Camera摄像头特定应用杂谈
2022 latest algorithm analysis and handwritten code interview analysis
Data science and Computational Intelligence: connotation, paradigm and opportunity
Understand chisel language thoroughly 15. Detailed explanation of chisel module (II) -- chisel module nesting and Alu implementation
TiDB 执行计划概览
MySQL数据库优化的这几种方式你都知道吗?
原来何恺明提出的MAE还是一种数据增强!上交&华为基于MAE提出掩蔽重建数据增强,优于CutMix、Cutout和Mixup!...