[InterviewBit] Salutes

Salutes

  • Time :
  • Space :
1
2
3
4
5
6
7
8
9
long Solution::countSalutes(string A) {
long res = 0, now = 0;
for(auto ch : A) {
if(ch == '>') now++;
else res += now;
}
return res;
}

Author: Song Hayoung
Link: https://songhayoung.github.io/2022/11/21/PS/interviewbit/salutes/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.