2026年华为招聘软件工程师面试全解析与答案.docxVIP

  • 0
  • 0
  • 约6.99千字
  • 约 20页
  • 2026-11-11 发布于福建
  • 举报

2026年华为招聘软件工程师面试全解析与答案.docx

第PAGE页共NUMPAGES页

2026年华为招聘:软件工程师面试全解析与答案

一、编程能力测试(5题,每题20分,共100分)

1.题目:

编写一个函数,实现快速排序算法。输入一个整数数组,输出排序后的数组。要求:不得使用递归,使用迭代方式实现。

答案:

java

importjava.util.Stack;

publicclassQuickSortIterative{

publicstaticint[]quickSort(int[]arr){

if(arr==null||arr.length=1){

returnarr;

}

StackIntegerstack=newStack();

stack.push(0);

stack.push(arr.length-1);

while(!stack.isEmpty()){

intend=stack.pop();

intstart=stack.pop();

intpivotIndex=partition(arr,start,end);

if(pivotIndex-1start){

stack.push(start);

stack.push(pivotIndex-1);

}

if(pivotIndex+1end){

sta

文档评论(0)

1亿VIP精品文档

相关文档