↓ 跳过正文
  1. Tags/

阿里巴巴

2017

阿里面试算法题(转载)

·9433 字·19 分钟
I want to match those five numbers 3, 7, 8, 9, 87 through regular express. Here is my thought: match those four numbers 3 7 8 9 var ^[3|7|8|9]\( match number 87 var ^87\) Then combine them together, (^[3|7|8|9]\(|^87\)). With some test, it seems correct. Is there any way to do that more efficiently? Q: 已知三个升序整数数组a[l], b[m]和c[n]。请在三个数组中各找一个元素,使得组成的三元组距离最小。 三元组的距离定义是:假设a[i]、b[j]和c[k]是一个三元组,那么距离为: Distance = max(|a[i] – b[j]|, |a[i] – c[k]|, |b[j] – c[k]|) 请设计一个求最小三元组距离的最优算法,并分析时间复杂度。