We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. Practice
  2. Data Structures
  3. Stacks
  4. Simple Text Editor
  5. Discussions

Simple Text Editor

Problem
Submissions
Leaderboard
Discussions

    You are viewing a single comment's thread. Return to all comments →

  • Radhekrsna 4 years ago+ 0 comments

    ***C++:-

    int N;
        cin>>N;
        stack<string>stk;
        string st;
        while(N--){
            int n; cin>>n;
            if(n==1){
                string str;
                cin>>str;
                stk.push(st); 
                st+=str;
            }
            else if(n==2){
                int k;cin>>k;
                 stk.push(st);
                st.erase(st.size()-k);
            }
            else if(n==3){
                int k;cin>>k;
                cout<<st[k-1]<<endl; 
            }
            else{
                st = stk.top();  
                stk.pop();
            }
        }
    

    109|
    Permalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature