C++ Confusion Buster: Your Easy Guide to C++ !
Reverse String code [C++] : Use any one way :
// Reverse a string// Shyam Sunder Kanth// Insta : still_23.6_8#include<iostream>#include<algorithm>#include<stack>using namespace std;int main(){string str = "Hello";// Way-1 : Using functionreverse(str.begin(), str.end());// Way-2 : Two pointer methodfor(int i =0,j=str.length()-1;i<=j;i++,j--){swap(str[i],str[j]);}// Way -3// Using stackstack<char> st;for(int i=0;i<str.length();i++){st.push(str[i]);}string res = "";while(!st.empty()){char ch = st.top();res = res + ch;st.pop();}cout<<res;return 0;}
Hey, thanks for watching our video about String Reversal ! In this video we’ll walk you through:
Concept
Ways
Code
All codes are available at my GitHub account, check them out here:
https://github.com/shyamkanth/Placements
Check out other videos from DS Revealed playlist: https://www.youtube.com/playlist?list=PLNXqJgOsTCZOB60T9HDhMf_o8RXbNWgqS
Check out our channel here: https://www.youtube.com/@DevelopersByte
Find us at: https://shyamkanth.github.io/
Timestamps:
0:00 Intro
0:55 Concept
02:40 Ways
03:30 Using function
05:20 Code
06:35 Two-pointer method
10:55 Code
13:00 Using Stack
16:50 Code
18:52 Outro
About our channel:
Our channel is about Revealing the secrets of Data Structure. We cover lots of cool stuff such as Codes, Concepts and Implementations.
Check out our channel here: https://www.youtube.com/@DevelopersByte
Don’t forget to subscribe!
Follow me on social media:
Get updates or reach out to Get updates on our Social Media Profiles!
GitHub: https://github.com/shyamkanth/
Instagram: https://instagram.com/still_23.6_8
Instagram personal: https://instagram.com/itz_sammmii
No comments:
Post a Comment