当前位置: 首页 > news >正文

怎么做qq刷赞网站北京seo

怎么做qq刷赞网站,北京seo,网站推广做百度还是360,昆山设计公司【每日刷题】Day75 🥕个人主页:开敲🍉 🔥所属专栏:每日刷题🍍 🌼文章目录🌼 1. 1833. 雪糕的最大数量 - 力扣(LeetCode) 2. 面试题 17.14. 最小K个数 - 力扣…

【每日刷题】Day75

🥕个人主页:开敲🍉

🔥所属专栏:每日刷题🍍

🌼文章目录🌼

1. 1833. 雪糕的最大数量 - 力扣(LeetCode)

2. 面试题 17.14. 最小K个数 - 力扣(LeetCode)

3. 面试题 01.01. 判定字符是否唯一 - 力扣(LeetCode)

1. 1833. 雪糕的最大数量 - 力扣(LeetCode)

//思路:记数排序。

//记数排序

void CountSort(int* arr,int size)

{

    int* hash = (int*)calloc(100001,sizeof(int));

    int max = 0;

    int count = 0;

    for(int i = 0;i<size;i++)

    {

        hash[arr[i]]+=1;

        if(arr[i]>max)

            max = arr[i];

    }

    for(int i = 1;i<=max;i++)

    {

        while(hash[i])

        {

            arr[count++] = i;

            hash[i]--;

        }

    }

}

int maxIceCream(int* costs, int costsSize, int coins)

{

    int ans = 0;

    CountSort(costs,costsSize);

    for(int i = 0;i<costsSize;i++)

    {

        if(coins-costs[i]>=0)

        {

            coins-=costs[i];

            ans++;

        }

        else

            break;

    }

    return ans;

}

2. 面试题 17.14. 最小K个数 - 力扣(LeetCode)

//思路:TopK问题。采用堆排序将所求的K个数排入堆底。

//交换

void Swap(int* x, int* y)

{

    int tmp = *x;

    *x = *y;

    *y = tmp;

}

//向下调整

void AdjustDown(int* arr, int parents, int size)

{

    int child = parents * 2 + 1;

    while (child < size)

    {

        if (child + 1 < size && arr[child + 1] < arr[child])

            child++;

        if (arr[child] < arr[parents])

            Swap(&arr[child], &arr[parents]);

        else

            break;

        parents = child;

        child = parents * 2 + 1;

    }

}

void TopK(int* arr, int size, int k)

{

    for (int i = (size - 2) / 2; i >= 0; i--)

    {

        AdjustDown(arr, i, size);

    }

    while (k)//循环K次,每次将最小的数排入堆底

    {

        Swap(&arr[0], &arr[size - 1]);

        k--;

        size--;

        AdjustDown(arr, 0, size);

    }

}

int* smallestK(int* arr, int arrSize, int k, int* returnSize)

{

    TopK(arr,arrSize,k);

    int* ans = (int*)malloc(sizeof(int)*100000);

    int count = 0;

    for(int i = arrSize-1;i>=arrSize-k;i--)

    {

        ans[count++] = arr[i];//拿取堆底的K个数

    }

    *returnSize = count;

    return ans;

}

3. 面试题 01.01. 判定字符是否唯一 - 力扣(LeetCode)

//思路①:哈希

bool isUnique(char* astr)

{

    int hash[27] = {0};

    for(int i = 0;i<strlen(astr);i++)

    {

        hash[astr[i]-'a']+=1;

    }

    for(int i = 0;i<27;i++)

    {

        if(hash[i]>1)

            return false;

    }

    return true;

}

//思路②:排序+一次遍历。选用插入排序,不需要开辟额外的空间,效率也不错。

//插入排序

void Insert(char* arr)

{

    for(int i = 0;i<strlen(arr)-1;i++)

    {

        int end = i+1;

        char tmp = arr[end];

        while(end-1>=0)

        {

            if(arr[end-1]>tmp)

                arr[end] = arr[end-1];

            else

                break;

            end--;

        }

        arr[end] = tmp;

    }

}


 

bool isUnique(char* astr)

{

    if(!strlen(astr))

        return true;

    Insert(astr);

    for(int i = 0;i<strlen(astr)-1;i++)

    {

        if(astr[i]==astr[i+1])

            return false;

    }

    return true;

}

http://www.hengruixuexiao.com/news/34140.html

相关文章:

  • 做片子 我们是认真的网站域名停靠
  • 福田蒙派克e参数配置seo工作流程
  • 网站开发怎么谈客户大数据营销系统
  • 个人网站做淘宝客违规武汉网络推广网络营销
  • 网站引导页模板厦门seo推广
  • 自己怎么设计公主裙现在百度怎么优化排名
  • 珠海专业网站制作公司软文范例大全800字
  • 域名弄好了网站怎么建设seo博客写作
  • 杭州装饰网站建设出售网站平台
  • 怎么做钓qq密码网站网站关键词收录查询
  • 怎么做淘宝客优惠劵网站网络营销策略名词解释
  • 网站怎么做分类聚合竞价托管收费标准
  • 自己做网站挣钱不推广方法
  • dwcs5怎么把做的网站适屏软文技巧
  • 做一个网站需要多少钱 怎么做肇庆百度快速排名
  • 手机网站优化公司市场营销在线课程
  • 做虚假网站犯法吗苏州首页排名关键词优化
  • 许昌网站优化天津seo托管
  • ipad网站开发韩国vs加纳分析比分
  • 怎么修复网站死链购买链接怎么买
  • b2c电商网站开发手机如何制作网站教程
  • 网站权重的提升企业网络营销策略分析案例
  • 南通高端网站建设营销渠道策略有哪些
  • 学什么可以先做网站seo指什么
  • 网站添加cms企业推广是什么意思
  • 香港最新消息新闻seo软件
  • wordpress应用app主题广告优化师工作内容
  • 池州做网站培训网站推广宣传语
  • 网站搭建怎么做百度关键词优化工具
  • 合肥建设网站查询怎样申请自己的电商平台