新浪8.18算法笔经

1、选择题10道略过
2、算法题:
1)魔法森林,LeetCode 354. 俄罗斯套娃信封问题 未ac
    思路:将信封的宽度先排序,则题目转为最长上升子序列问题
class Solution(object):
    def maxEnvelopes(self, envelopes):
        """
        :type envelopes: List[List[int]]
        :rtype: int
        """
        # 先将信封按宽度排序
        envelopes.sort(key=lambda x:(x[0],-x[1]))
        # 将问题转换为最长上升子序列
        # dp[i]表示第i个信封可以装多少个信
        dp = [1]*len(envelopes)
        dp[0] = 1
        ans = 1
        for i in range(1,len(envelopes)):
            for j in range(i):
                if envelopes[i][1] > envelopes[j][1]:
                    dp[i] = max(dp[i],dp[j]+1)
                ans = max(ans,dp[i])
        # print(dp)
        # print(envelopes)
        return ans
2)LeetCode 283. 移动零 (全ac)
class Solution(object):
    def moveZeroes(self, nums):
        """
        :type nums: List[int]
        :rtype: None Do not return anything, modify nums in-place instead.
        """
        if len(nums)<=1:
            return nums
        p = 0
        while p<len(nums) and nums[p] != 0:
            p+=1
        if p == len(nums):
            return nums
        q = p+1
        while p<q and q<len(nums):
            if nums[q] != 0:
                nums[p],nums[q] = nums[q],nums[p]
                p+=1
            q+=1
        return nums

3、问答题
1)激活函数 
     i)常见激活函数及其导数  ii)为什么sigmoid和tanh会导致梯度消 iii)relu比sigmoid和tanh好在哪 relu本身有哪些局限如何改进
2)个性化推荐
     i)数据集负样本如何设计 ii)采用什么模型和算法提取用户和新闻之间的联系 iii)通过什么方式表征用户与新闻的关系



#算法工程师##新浪##笔经#
全部评论
有收到面试通知吗🤣
点赞 回复
分享
发布于 2021-08-28 18:51
请问收到面试了吗
点赞 回复
分享
发布于 2021-09-03 17:29
小红书
校招火热招聘中
官网直投

相关推荐

点赞 2 评论
分享
牛客网
牛客企业服务