当前位置: 首页 > 面试经验 >

哔哩哔哩bilibili9.9笔试 后台B端

优质
小牛编辑
89浏览
2023-09-09

哔哩哔哩bilibili9.9笔试 后台B端

一个小时切完了,听说b站没多少hc,求进面

题目数据规模很小,暴力就完了,秋招最水的一场笔试

1 SQL 黄金白银青铜主播

select ala1.anchor_id
from (select anchor_id, sum(live_revenue) rev from anchor_live_revenue_record group by anchor_id
    having rev > 100 order by rev desc) ala1
where ala1.rev in (select distinct sum(live_revenue) rev from anchor_live_revenue_record
    group by anchor_id having rev > 100 order by rev desc)
order by ala1.anchor_id desc

2 符合条件的子数组个数,n2就能过,维护最值即可

class Solution {
public:
    int subArrNum(vector<int> &arr) {
        int cnt = 0;
        for (int i = 0; i < arr.size(); i++) {
            int maxn = -1;
            int minn = 10001;
            for (int j = i; j < arr.size(); j++) {
                maxn = max(maxn, arr[j]);
                minn = min(minn, arr[j]);
                if (maxn - minn > 2) {
                    break;
                }
                cnt++;
            }
        }

        return cnt;
    }
};

3 符合条件的子集个数,罕见地直接递归就过完了

class Solution {
public:
    void recur(vector<int>& nums, vector<int>& cur, int k, int& cnt, int index) {
        if (cur.size() != 0) {
            int last = cur[cur.size() - 1];
            int ok = 1;
            for (int i = 0; i < cur.size() - 1; i++) {
                if (abs(last - cur[i]) == k) {
                    ok = 0;
                    break;
                }
            }

            if (!ok) {
                return;
            } else {
                cnt++;
            }
        }

        for (int i = index + 1; i < nums.size(); i++) {
            cur.push_back(nums[i]);
            recur(nums, cur, k, cnt, i);
            cur.resize(cur.size() - 1);
        }
    }

    int subSetNum(vector<int>& nums, int k) {
        int cnt = 0;
        vector<int> cur;
        recur(nums, cur, k, cnt, -1);
        return cnt;
    }
};

 类似资料: