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

HackerEarth Terrible Chandu problem solution

YASH PAL, 31 July 202414 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 *

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

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