阿里(高德)-算法-一面
1.自我介绍
2.这部分就不写了,面试官有点迷
(问我觉得把label-encoder处理后的特征放进lightgbm里面合适吗,0.0)
3.编程题:
给定一个长度为N的未排序的整数数组,找出最长连续序列的长度,N<100w。 例如, 给出 [100, 4, 200, 1, 3, 2], 这个最长的连续序列是 [1, 2, 3, 4]。返回所求长度: 4。
https://leetcode-cn.com/problems/longest-consecutive-sequence/
AC
class Solution: def longestConsecutive(self, nums: List[int]) -> int: longest_streak = 0 num_set = set(nums) for num in num_set: if num - 1 not in num_set: current_num = num current_streak = 1 while current_num + 1 in num_set: current_num += 1 current_streak += 1 longest_streak = max(longest_streak, current_streak) return longest_streak
2021届秋招算法岗笔经面经 文章被收录于专栏
小白一枚,有误的地方还请大佬们指正