Skip to content
mtMatt.Page

mtMatt.Page

a common page

  • C++學習心得
  • APCS
    • APCS325
    • APCS實作題
  • 競賽題
  • 解題(解題系統)
  • MISC

HackerRank Warm-up 2.Counting Valleys , in C++

2021 年 7 月 13 日2022 年 5 月 12 日mattQQhackerRank, OJ, onlineJudge解題(解題系統)

題目連結:Counting Valleys | HackerRank

唯一要注意的是山谷的定義

int countingValleys(int steps, string path) {
    int ct=0,h=0;
    bool islow=false;
    for(auto a:path){
        if(a=='D'){
            h--;
        }else{
            h++;
        }
        if(h<0){
            if(!islow){
                ct++;
                islow=true;
            }
        }else{
            islow=false;
        }
    }
    return ct;
}

文章導覽

HackerRank Warm-up 1.Sales by Match, in C++
HackerRank Warm-up 3.Jumping on the Clouds, in C++

彙整

近期文章

  • LeetCode 1. Two Sum 2022 年 5 月 22 日
  • [版本更新] 快速回顧 微軟發布 KB5013943 (Windows 11 作業系統組建 22000.675) 2022 年 5 月 18 日
  • 在 Linux 上用 Fcitx5 搭配新酷音 2022 年 5 月 12 日
  • 籠中鳥-大考中心試卷 2022 年 4 月 25 日
  • 孫子兵法-謀攻篇帶來的啟示 2022 年 4 月 3 日
  • 圖論測資生成器 2022 年 3 月 20 日
  • 2021 資訊之芽入芽考 E. 大整數 2022 年 1 月 26 日
  • 安裝 MX Linux MX-21 後,我做了一些系統設定 2022 年 1 月 26 日
  • APCS 2022/1/9 2022 年 1 月 10 日
  • 一個非常暴力的常數優化 2022 年 1 月 1 日

標籤

95全國能力競賽 (2) ABC (4) algorithm (1) apcs (14) boshiamy (1) clearLinux (2) coding (1) competition (20) dataStructure (2) debian (1) disjointSets (1) fcitx (2) fcitx-chewing (1) fcitx5 (1) gcin (1) grub (1) hackerRank (19) iBus (1) LeetCode (1) linux (5) macOS (1) mxLinux (1) nhspc (4) OJ (41) onlineJudge (41) reading (2) review (5) scim (1) sproutOJ (2) swupd (1) virtualBox (1) windows (2) windows11 (1) windowsUpdate (1) 全國賽 (4) 嘸蝦米 (1)
Copyright © All rights reserved
↑