URI Online judge Solution 1069 Diamonds and Sand
URI Online Judge Solution 1069 Diamonds and Sand | Data structures
URI Main Problem Link - https://www.urionlinejudge.com.br/judge/en/problems/view/1069
Problem Name: URI Problem 1069 Diamonds and Sand
Problem Number : URI Problem 1069 Diamonds and Sand Solution
Online Judge : URI Online Judge Solution
Level: Data structures
Solution Language : C, C plus plus
URI Solution 1069 Diamonds and Sand Code in CPP:
#include <iostream> using namespace std; int main() { int n, size, counter, tmp; string s; cin >> n; for (int i = 0; i < n; ++i) { cin >> s; size = s.length(); counter = 0; tmp = 0; for (int j = 0; j < size; ++j) { if(s[j] == '<') tmp++; if (s[j] == '>' && tmp > 0){ counter++; tmp--; } } cout << counter << endl; } return 0; }
No comments:
Write commentsTo know more about the problem, give us your valuable commment. We'll try to help you. Thanks