- 1
- 0
- 约7.59千字
- 约 21页
- 2026-11-05 发布于福建
- 举报
第PAGE页共NUMPAGES页
2026年创新科技公司研发工程师面试指南及答案
一、编程基础(共5题,每题10分,总分50分)
题目1(10分)
请用Python实现一个函数,该函数接收一个字符串参数,返回该字符串中所有唯一字符的列表。例如,输入hello,返回[h,e,l,o]。
python
defunique_chars(s):
returnlist(set(s))
答案解析:使用Python内置的set数据结构可以快速去除重复字符,然后将其转换回列表。这种方法时间复杂度为O(n),空间复杂度也为O(n)。
题目2(10分)
请用C++实现一个函数,该函数对一个整数数组进行快速排序,并返回排序后的数组。要求不使用额外的存储空间。
cpp
includevector
usingnamespacestd;
intpartition(vectorintarr,intlow,inthigh){
intpivot=arr[high];
inti=low-1;
for(intj=low;jhigh;j++){
if(arr[j]pivot){
i++;
swap(arr[i],arr[j]);
}
}
swap(arr[i+1],arr[high]);
returni+1;
}
vectorintqui
原创力文档

文档评论(0)