counting valleys hackerrank solution in c++
C++
#include <bits/stdc++.h>
using namespace std;
/*
* Prosen Ghosh
* American International University - Bangladesh (AIUB)
*
*/
int main() {
int n,updown = 0,res = 0;
char c;
cin >> n;
for(int i = 0; i++ < n;){
cin >> c;
if(c == 'U')updown++;
else updown--;
if(updown == 0 && c == 'U')res++;
}
cout << res << endl;
return 0;
}
Also in C++:
- Title
- including cpp header file in c++
- Category
- C++
- Title
- how to cout in c++
- Category
- C++
- Title
- run program until ctrl-d c++
- Category
- C++
- Title
- screen record ios simulator
- Category
- C++
- Title
- c++ vector iterator
- Category
- C++
- Title
- how to run c++ file mingw cmd
- Category
- C++
- Title
- cpp create lambda with recursion
- Category
- C++
- Title
- insert function in c++ vector
- Category
- C++
- Title
- range based for loop c++
- Category
- C++
- Title
- c++ try
- Category
- C++
- Title
- print type cpp
- Category
- C++
- Title
- file objects in c++
- Category
- C++
- Title
- cin.ignore
- Category
- C++
- Title
- what is meaning of 64 bit integer in c++
- Category
- C++
- Title
- c++ class template
- Category
- C++
- Title
- is not a nonstatic data member or base class of class
- Category
- C++
- Title
- split string at index c++
- Category
- C++
- Title
- how to find the number of cycles in a graph C++
- Category
- C++
- Title
- how to get a letter from the user c++ string
- Category
- C++
- Title
- Html tabulation
- Category
- C++
- Title
- declaring 2d vector in c++
- Category
- C++
- Title
- c++ remove item from list
- Category
- C++
- Title
- multiset c++
- Category
- C++
- Title
- creare array con c++
- Category
- C++
- Title
- how to find the size of a character array in c++
- Category
- C++
- Title
- leveling system c++
- Category
- C++
- Title
- how to create object in c++
- Category
- C++
- Title
- how to compile opencv c++ in ubuntu
- Category
- C++
- Title
- c++ formatting
- Category
- C++
- Title
- do while loop c++
- Category
- C++
- Title
- c++ pointers
- Category
- C++
- Title
- Runtime Error: Runtime ErrorAbort signal from abort(3) (SIGABRT)
- Category
- C++
- Title
- ue4 c++ overlapping functions cpp setup
- Category
- C++
- Title
- initialize 3d vector c++
- Category
- C++
- Title
- registering a new QML type
- Category
- C++
- Title
- min heap declaration in c++ stl
- Category
- C++
- Title
- C++ string format ctime
- Category
- C++
- Title
- visual studio 2019 read and write text file c++
- Category
- C++
- Title
- least number of coins to form a sum
- Category
- C++
- Title
- loop through array c++
- Category
- C++
- Title
- call by reference c++ example
- Category
- C++
- Title
- how to declare a vector in c++
- Category
- C++
- Title
- char* to int in cpp
- Category
- C++
- Title
- how to make a 2d vector in c++
- Category
- C++
- Title
- assegnare valori in c++
- Category
- C++
- Title
- c++ remove element from vector
- Category
- C++
- Title
- c++ typedef
- Category
- C++
- Title
- making random numbers in c++
- Category
- C++
- Title
- inserting an element in an set c++
- Category
- C++
- Title
- how to round to nearest whole number unity
- Category
- C++
- Title
- c++ program to find gcd of 3 numbers
- Category
- C++
- Title
- c++ program to input and print text using Dynamic Memory Allocation.loop
- Category
- C++
- Title
- how to read and write in a file c++
- Category
- C++
- Title
- c++ how to make a negative float positive
- Category
- C++
- Title
- max heap c++ stl;
- Category
- C++
- Title
- char vector to string c++
- Category
- C++
- Title
- runtime error in c++
- Category
- C++
- Title
- max in c++
- Category
- C++
- Title
- nginx linux
- Category
- C++
- Title
- c++ empty stream
- Category
- C++
- Title
- opencv compile c++
- Category
- C++
- Title
- stl sort in c++
- Category
- C++
- Title
- *min_element in c++
- Category
- C++
- Title
- how to append one vector to another c++
- Category
- C++
- Title
- c++ sql
- Category
- C++
- Title
- maximum subarray sum in c++
- Category
- C++
- Title
- int random string generator c++
- Category
- C++
- Title
- compile c++ linux
- Category
- C++
- Title
- set c++
- Category
- C++
- Title
- graph using djacency matrix c++
- Category
- C++
- Title
- tellg and seekg c++
- Category
- C++
- Title
- how to get the prime number in c++ where time complexity is 0(log n)
- Category
- C++
- Title
- random number generator c++
- Category
- C++
- Title
- remove value from vector c++
- Category
- C++
- Title
- how to print for limited decimal values in c++
- Category
- C++
- Title
- how to iterate through array in c++
- Category
- C++
- Title
- c++ declare char
- Category
- C++
- Title
- c++ variable argument
- Category
- C++
- Title
- map insert c++
- Category
- C++
- Title
- is TLE means my code is correct but taking more time to computr
- Category
- C++
- Title
- how to get input from the console in c++
- Category
- C++
- Title
- Html tab
- Category
- C++
- Title
- how to check type in c++
- Category
- C++
- Title
- c++ push multiple elements to vector
- Category
- C++
- Title
- change int to string cpp
- Category
- C++
- Title
- ue4 c++ enum
- Category
- C++
- Title
- msdn parse command line
- Category
- C++
- Title
- pyqt connect
- Category
- C++
- Title
- Create a program that finds the minimum value in these numbers
- Category
- C++
- Title
- how to make a switch case statement in c++
- Category
- C++
- Title
- iterate through unordered_map c++ in reverse order
- Category
- C++
- Title
- cs1955 unity vector3
- Category
- C++
- Title
- root to leaf path print
- Category
- C++
- Title
- c++ isalphanum
- Category
- C++
- Title
- c++ code to print hello world
- Category
- C++
- Title
- how to iterate trough a vector in c++
- Category
- C++
- Title
- how to calculate inverse trigonometric values in c++
- Category
- C++
- Title
- c++ reading string
- Category
- C++
- Title
- c++ reverse vector
- Category
- C++
- Title
- file format not recognized treating as linker script c++
- Category
- C++