{"results": {"id": 701595, "problem_name": "Reverse a String", "problem_type": 1, "problem_type_text": "Function", "publish": 1, "publish_date": "2019-10-30 15:54:49", "slug": "reverse-a-string", "problem_level": -1, "problem_level_text": "Basic", "difficulty": "Basic", "marks": 1, "is_sample_input_modified": 1, "custom_input_format": "<p><span style=\"font-size: 12pt;\">The first line contains a String <strong>s.</strong></span></p><p><span style=\"font-size: 12pt;\"><strong>Example:</strong></span></p><pre><span style=\"font-size: 12pt;\">Geeks</span></pre>", "multiple_testcase": 1, "content_type": 1, "visibility_type": 1, "visibility_text": "public", "is_contest_problem": 0, "contest_slug": null, "can_add_interview_link": false, "can_edit_all_submissions_link": true, "has_all_submissions_button": false, "all_submissions": 627410, "accuracy": "69.49%", "is_user_login": 0, "is_private_tag_visible": false, "problem_category": 0, "related_courses": {}, "tags": {"company_tags": [], "topic_tags": ["Strings"]}, "problem_question": "<p><span style=\"font-size: 18.6667px;\">Given a string <strong>s</strong>, reverse the string.</span></p><p><span style=\"font-size: 14pt;\"><strong>Examples:</strong></span></p><pre><span style=\"font-size: 14pt;\"><strong>Input: </strong>s = \"Geeks\"\n<strong>Output: </strong>\"skeeG\"\n</span></pre><pre><span style=\"font-size: 14pt;\"><strong>Input: </strong>s = \"for\"\n<strong>Output: </strong>\"rof\"</span></pre><pre><span style=\"font-size: 14pt;\"><strong>Input: </strong>s = \"a\"\n<strong>Output: </strong>\"a\"</span></pre>", "contributor": "", "test_cases": "Geeks", "article_existence": 4, "article_list": ["https://www.geeksforgeeks.org/cpp-program-to-print-reverse-of-a-string-using-recursion/", "https://www.geeksforgeeks.org/reverse-a-string-in-c-cpp-different-methods/", "https://www.geeksforgeeks.org/reverse-a-string-in-java/", "https://www.geeksforgeeks.org/string-reverse/"], "can_edit_history": false, "can_edit_problem": false, "can_edit_problem_read_only": false, "author": "kadrun279n", "has_problem_solutions": true, "has_hints": true, "has_editorial": true, "can_view_hints": true, "track": "", "batch": "", "has_doubt_assistance": false, "extra": {"problem_languages": {"c": "C (gcc 5.4)", "cpp": "C++ (17)", "java": "Java (21)", "python3": "Python3", "csharp": "C#", "javascript": "JavaScript"}, "default_lang": null, "default_code": null, "initial_user_func": {"c": {"initial_code": "#include <stdio.h>\n#include <string.h>\n\n// Function to reverse the string\nchar* reverseString(char* s);\n\nint main() {\n    int t;\n    scanf(\"%d\", &t);\n    while (t--) {\n        char s[1000001]; // Sufficient space for the input string\n        scanf(\"%s\", s);\n        printf(\"%s\\n\", reverseString(s));\n        printf(\"~%s\", \"\\n\");\n    }\n    return 0;\n}", "user_code": "char* reverseString(char* s) {\n    // Code Here\n    \n}", "created_at_timestamp": 1791270020.0, "updated_at_timestamp": 1791270020.0}, "cpp": {"initial_code": "// Initial Template for C++\n\n#include <bits/stdc++.h>\nusing namespace std;\n\n//Position this line where user code will be pasted.\n\nint main() {\n\n    int t;\n    cin >> t;\n    while (t--) {\n        string s;\n        cin >> s;\n        Solution ob;\n        cout << ob.reverseString(s) << endl;\n\n        cout << \"~\"\n             << \"\\n\";\n    }\n    return 0;\n}\n", "user_code": "class Solution {\n  public:\n    string reverseString(string& s) {\n        // code here\n        \n    }\n};\n", "created_at_timestamp": 1791270020.0, "updated_at_timestamp": 1791270020.0}, "java": {"initial_code": "// Initial Template for Java\n\nimport java.io.*;\nimport java.lang.*;\nimport java.util.*;\n\nclass Driver {\n    public static void main(String args[]) throws IOException {\n        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));\n        int t = Integer.parseInt(read.readLine());\n\n        while (t-- > 0) {\n            String str = read.readLine();\n            System.out.println(new Solution().reverseString(str));\n\n            System.out.println(\"~\");\n        }\n    }\n}", "user_code": "class Solution {\n    public static String reverseString(String s) {\n        // code here\n        \n    }\n}", "created_at_timestamp": 1791270020.0, "updated_at_timestamp": 1791270020.0}, "python3": {"initial_code": "#Initial Template for Python 3\n\nif __name__ == \"__main__\":\n    t = int(input())\n    while (t > 0):\n        s = input()\n        ob = Solution()\n        print(ob.reverseString(s))\n        t = t - 1\n\n        print(\"~\")\n", "user_code": "class Solution:\n    def reverseString(self, s: str) -> str:\n        # code here", "created_at_timestamp": 1791270020.0, "updated_at_timestamp": 1791270020.0}, "csharp": {"initial_code": "using System;\nusing System.Collections.Generic;\n\nclass Program {\n    static void Main() {\n        int t;\n        t = Convert.ToInt32(Console.ReadLine());\n        while (t-- > 0) {\n            string s;\n            s = Console.ReadLine();\n            Solution ob = new Solution();\n            Console.WriteLine(ob.reverseString(s));\n\n            Console.WriteLine(\"~\");\n        }\n    }\n}", "user_code": "class Solution {\n    public string reverseString(string s) {\n        // code here\n        \n    }\n}", "created_at_timestamp": 1791270020.0, "updated_at_timestamp": 1791270020.0}, "javascript": {"initial_code": "// Initial Template for javascript\n\n'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => { inputString += inputStdin; });\n\nprocess.stdin.on('end', _ => {\n    inputString =\n        inputString.trim().split('\\n').map(string => { return string.trim(); });\n\n    main();\n});\n\nfunction readLine() { return inputString[currentLine++]; }\n\nfunction main() {\n    let t = parseInt(readLine());\n    let i = 0;\n    for (; i < t; i++) {\n        let str = readLine().trim();\n        let obj = new Solution();\n        let res = obj.reverseString(str);\n        console.log(res);\n\n        console.log(\"~\");\n    }\n}", "user_code": "/**\n * @param {string} s\n * @return {string}\n */\n\nclass Solution {\n\n    reverseString(s) {\n        // code here\n        \n    }\n}", "created_at_timestamp": 1791270020.0, "updated_at_timestamp": 1791270020.0}}, "input": "Geeks", "input_format": {"arguments": "s", "datatype": "STRING", "constraints": [{"allowed_characters": "a-zA-Z", "min_length": "1", "max_length": "10^6", "show_in_preview": false, "allowed_char_show_in_preview": true}], "show_constraints_in_problem": true}, "is_mtc_enabled": true}, "course_default_lang": null, "interview_links": [], "user_has_access_to_doubt_assistance": false, "editorial_type": "post", "associated_func_pid": null, "can_view_author_solution": false, "show_editorial_tab": true, "is_todays_potd": false, "visualizer_type": null, "input_format": {"arguments": "s", "datatype": "STRING", "constraints": [{"allowed_characters": "a-zA-Z", "min_length": "1", "max_length": "10^6", "show_in_preview": false, "allowed_char_show_in_preview": true}], "show_constraints_in_problem": true}, "constraints_display": "1 \u2264 s.size() \u2264 10^6\ns consists only of English alphabets", "time_to_solve": 15, "expected_time_complexity": "O(n)", "expected_auxiliary_space": "O(1)"}, "status": true}