从零单排力扣周赛_周赛273

本文同步发表于 个人博客

前言

感觉 l e e t c o d e leetcode leetcode 周赛不花时间,做一做还能保持一下手感,最重要的是能让人在周末早起。于是以后可能就会多打打 l e e t c o d e leetcode leetcode 了。

周赛273

AK时间: 21min

最终排名:

A 5963.反转两次的数字

给出数字 n n n R ( n ) R(n) R(n) 表示 n n n 翻转后去掉前导零的结果,要求判断 R ( R ( n ) ) R(R(n)) R(R(n)) 是否等于 n n n

0 ≤ n ≤ 1 0 6 0\le n\le 10^6 0n106

做法

判断 n n n 是否有后导 0 0 0,即 n n n 是否是 10 10 10 的倍数即可,特判 n = 0 n=0 n=0 的情况。

代码
class Solution {
   
public:
    bool isSameAfterReversals(int num) {
   
        return (num == 0 || num % 10 != 0);
    }
};

B 5964. 执行所有后缀指令

模拟题

做法

模拟即可

代码
class Solution {
   
public:
    vector<int> executeInstructions(int n, vector<int>& startPos, string s) {
   
        int m = s.size();
        vector<int> ans(m);
        for(int i = 0; i < m; i++){
   
            int ok = 0;
            int x = startPos[0], y = startPos[1];
            for(int j = i; j < m; j++){
   
                if(s[j] == 'L') y--;
                if(s[j] == 'R') y++;
                if(s
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值