Leetcode3014. 输入单词需要的最少按键次数 I

题目:


代码(首刷看解析 2024年2月21日):

class Solution {
public:
    int minimumPushes(string word) {
        int n = word.size();
        if (n <= 8) return n;
        int mo = n % 8;
        int x = n / 8;
        int res = 0;
        for (int i = 1; i < x + 1; ++i) {
            res += i * 8;
        }
        res += mo * (x + 1);
        return res;
    }
};

相关推荐

  1. leetCode58. 最后一个单词长度

    2024-02-21 17:14:01       37 阅读
  2. leetcode58 最后一个单词长度

    2024-02-21 17:14:01       33 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-21 17:14:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-21 17:14:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-02-21 17:14:01       82 阅读
  4. Python语言-面向对象

    2024-02-21 17:14:01       91 阅读

热门阅读

  1. NebulaGraph学习笔记-自定义池连接

    2024-02-21 17:14:01       44 阅读
  2. vue学习笔记

    2024-02-21 17:14:01       51 阅读
  3. 为什么使用 Redis,不用 Memcache 和 MongoDB?

    2024-02-21 17:14:01       48 阅读
  4. ADO.NET查询返回单个值

    2024-02-21 17:14:01       50 阅读
  5. 抽象方法与设计模式

    2024-02-21 17:14:01       47 阅读
  6. Qt之QChar类的数据转换

    2024-02-21 17:14:01       52 阅读
  7. Promise

    2024-02-21 17:14:01       53 阅读