小红书2024秋招后端开发(Java工程师、C++工程师等)

前几天做了美团,OPPO的秋招笔试题,然后又做了一场小红书,总体难度我觉得都差不多,涉及到的知识点要么是语法模拟,或者就是一些基础算法,所以这样看秋招编程题还是很简单的,对于笔试我们还要把除了算法题以为的选择题做好,比如我看还有好多MySQL之类的题,好了话不多说,我们来看一下小红书2024秋招后端开发的题,先贴个链接 题目测评链接——

目录

A题

题面

思路分析

代码实现

B题

题面

思路分析

代码实现

C题

题面

思路分析

代码实现

总结 

A题

题面

思路分析

首先我们按要求读入每个字符串,然后开一个map统计维护每个字符串的个数,如果该种字符串数量大于等于三,我们就将其放入pair数对里,因为题目中说明了排序输出方式,那我们需要对pair按要求开个cmp排个序就行了——

代码实现

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <climits>
#include <vector>
#define int long long
#define x first 
#define y second 
using namespace std;
const int N = 1e5 + 10;
typedef pair<string,int> PII;
PII p[N]; 
bool cmp(const PII &a,const PII &b)
{
    if(a.y != b.y) return (a.y > b.y);
    else return a.x < b.x;
}
void solve()
{
    map<string,int> mp;
    string str;
    while(cin >> str)   
    {
        mp[str]++;
    }
   // for(auto &c : mp) cout << c.x << " " << c.y << endl;
   int i = 0;
   for(auto &c : mp)
   {
       if(c.y >= 3)
       p[i++] = {c.x,c.y};      
   }
   sort(p , p + i ,cmp);
   for(int j = 0; j < i; j++) cout << p[j].x << endl;

}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t = 1;
    while(t -- ) solv
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值