Skip to content
Programming101
Programmingoneonone

Learn everything about programming

  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • 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
Programming101
Programmingoneonone

Learn everything about programming

HackerEarth Terrible Chandu problem solution

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

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes