不愧是字节跳动,这薪资给的还是很实在的

字节开奖

千呼万唤始出来,字节跳动终于开奖了。

相比于其他大厂,今年字节跳动的薪资仍然很有竞争力,甚至比今年薪资领跑的美团,还要高一丢丢。

这里整理了一下字节跳动「北京-后端开发」的开奖情况。

  • 白菜:硕士 985,26k*15,1W 签字费;
  • SP:硕士 985,(30k~32k)*15,签字费可谈,目前 1W~3W 都有;
  • SSP:硕士 985,(33k~35k)*15,签字费可谈,目前 1W~3W 都有;

PS. 字节今年的签字费都有为期一年的绑定期,绑定期离职,需要归还签字费

至于其他城市或其他岗位的开奖,可将上述情况作为基准来适当调整,从而得知基本情况。

举个 🌰,二线城市下移 3k~5k 为同档位大致开奖情况;前端岗位下移 1k~3k 为同档位大致开奖情况,算法岗位上移 2k~5k 为同档位大致开奖情况。

当然,如果某个「城市」或「岗位」感兴趣的人多,可以单独开一期推文,欢迎在评论区留言你感兴趣的「城市&岗位」。

...

回归主题。

来一道和「字节跳动」相关的算法题。

题目描述

平台:LeetCode

题号:1052

今天,书店老板有一家店打算试营业 customers.length 分钟。每分钟都有一些顾客(customers[i])会进入书店,所有这些顾客都会在那一分钟结束后离开。

在某些时候,书店老板会生气。 如果书店老板在第 i 分钟生气,那么 grumpy[i] = 1,否则 grumpy[i] = 0

当书店老板生气时,那一分钟的顾客就会不满意,不生气则他们是满意的。

书店老板知道一个秘密技巧,能抑制自己的情绪,可以让自己连续 X 分钟不生气,但却只能使用一次。

请你返回这一天营业下来,最多有多少客户能够感到满意的数量。

示例:

输入:customers = [1,0,1,2,1,1,7,5], grumpy = [0,1,0,1,0,1,0,1], X = 3

输出:16

解释:
书店老板在最后 3 分钟保持冷静。
感到满意的最大客户数量 = 1 + 1 + 1 + 1 + 7 + 5 = 16.

提示:

滑动窗口

由于「技巧」只会将情绪将「生气」变为「不生气」,不生气仍然是不生气。

  1. 我们可以先将原本就满意的客户加入答案,同时将对应的 customers[i] 变为 0。

  2. 之后的问题转化为:在 customers 中找到连续一段长度为 minutes 的子数组,使得其总和最大。这部分就是我们应用技巧所得到的客户。

Java 代码:

class Solution {
    public int maxSatisfied(int[] customers, int[] grumpy, int minutes) {
        int n = customers.length, ans = 0;
        for (int i = 0; i < n; i++) {
            if (grumpy[i] == 0) {
                ans += customers[i];
                customers[i] = 0;
            }
        }
        int cur = 0, max = 0;
        for (int i = 0; i < n; i++) {
            cur += customers[i];
            if (i >= minutes) cur -= customers[i - minutes];
            max = Math.max(max, cur);
        }
        return ans + max;
    }
}

C++ 代码:

class Solution {
public:
    int maxSatisfied(vector<int>& customers, vector<int>& grumpy, int minutes) {
        int n = customers.size(), ans = 0;
        for (int i = 0; i < n; i++) {
            if (grumpy[i] == 0) {
                ans += customers[i];
                customers[i] = 0;
            }
        }
        int cur = 0, max_val = 0;
        for (int i = 0; i < n; i++) {
            cur += customers[i];
            if (i >= minutes) cur -= customers[i - minutes];
            max_val = max(max_val, cur);
        }
        return ans + max_val;
    }
};

Python 代码:

class Solution:
    def maxSatisfied(self, customers: List[int], grumpy: List[int], minutes: int) -> int:
        n, ans = len(customers), 0
        for i in range(n):
            if grumpy[i] == 0:
                ans += customers[i]
                customers[i] = 0
        cur, maxv = 00
        for i in range(n):
            cur += customers[i]
            if i >= minutes:
                cur -= customers[i - minutes]
            maxv = max(maxv, cur)
        return ans + maxv

TypeScript 代码:

function maxSatisfied(customers: number[], grumpy: number[], minutes: number): number {
    let n = customers.length, ans = 0;
    for (let i = 0; i < n; i++) {
        if (grumpy[i] === 0) {
            ans += customers[i];
            customers[i] = 0;
        }
    }
    let cur = 0, maxv = 0;
    for (let i = 0; i < n; i++) {
        cur += customers[i];
        if (i >= minutes) cur -= customers[i - minutes];
        maxv = Math.max(maxv, cur);
    }
    return ans + maxv;  
};
  • 时间复杂度:
  • 空间复杂度:

最后

巨划算的 LeetCode 会员优惠通道目前仍可用 ~

使用福利优惠通道 leetcode.cn/premium/?promoChannel=acoier,年度会员 有效期额外增加两个月,季度会员 有效期额外增加两周,更有超大额专属 🧧 和实物 🎁 福利每月发放。

我是宫水三叶,每天都会分享算法知识,并和大家聊聊近期的所见所闻

欢迎关注,明天见。

更多更全更热门的「笔试/面试」相关资料可访问排版精美的 合集新基地 🎉🎉

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值