Skip to content
Programmingoneonone
Programmingoneonone
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
    • Cybersecurity
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerEarth Terrible Chandu problem solution

YASH PAL, 31 July 202411 February 2026
In this HackerEarth Terrible Chandu problem solution Chandu is a bad student. Once his teacher asked him to print the reverse of a given string. He took three hours to solve it. The teacher got agitated at Chandu and asked you the same question. Can you solve it?
HackerEarth Terrible Chandu problem solution

HackerEarth Terrible Chandu problem solution.

#include <bits/stdc++.h>
using namespace std;
int main()
{
string s, s1;
int t;
for(cin >> t;t--;)
{
cin >> s;

// Reverse the string

// Solution 1

for(int i = 0;i < s.length() / 2;++i)
swap(s[i], s[s.length() - i - 1]);
cout << s << endl;

// Solution 2
/*
s1 = ""
for(int i = s.length() - 1;i >= 0;--i)
s1 += s[i];
cout << s1 << endl;

// Solution 3

reverse(s.begin(), s.end());
cout << s << endl;
*/
}
return 0;
}

Second solution

tc = int(raw_input())
while tc>0:
tc = tc - 1
s = raw_input()
print s[::-1]
coding problems solutions HackerEarth HackerEarth

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes