Hi. As I practice on various coding platforms, I keep on sharing my solutions as a blog post for me to refer back in future and also broadly for anyone searching for the same.
With this, let's begin with today's problem :-
Problem Name - Word
Problem Code - 59-A
Problem Link - https://codeforces.com/problemset/problem/59/A
How I solved it :-
Language used : C++
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define MOD 1000000007
#define endl '\n'
#define FAST \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define T \
ll t; \
cin >> t; \
while (t--)
int main(void)
{
FAST;
// test cases :-
string s;
cin >> s;
int c1 = 0, c2 = 0;
for (int i = 0; i < s.size(); i++)
{
if (s[i] >= 'a' && s[i] <= 'z')
c2++;
else
c1++;
}
if (c1 > c2)
transform(s.begin(), s.end(), s.begin(), ::toupper);
else
transform(s.begin(), s.end(), s.begin(), ::tolower);
cout << s;
return 0;
}
Highlights : Learnt about the 'transform' function in C++ : https://www.educative.io/answers/what-is-the-transform-function-in-cpp