Sunday, May 7, 2017

URI Online judge Solution 1069 Diamonds and Sand

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 Online judge Solution 1069 Diamonds and Sand

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 comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.