Decompressing a stringMax. score: 100Given a compressed string find the corresponding decompressed string.INPUT:Accept a compressed string.OUTPUT:Print the decompressed string.SAMPLE INPUT a10b5z4x1SAMPLE OUTPUT aaaaaaaaaabbbbbzzzzxTime Limit: 5.0 sec(s) for each input file.Memory Limit: 256 MBSource Limit: 1024 KBMarking Scheme: Score is assigned if any testcase passes.Allowed Languages: Bash, C, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java 8, JavaScript(Node.js), Julia, Kotlin, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, TypeScript, Visual Basic
Question
Decompressing a stringMax. score: 100Given a compressed string find the corresponding decompressed string.INPUT:Accept a compressed string.OUTPUT:Print the decompressed string.SAMPLE INPUT a10b5z4x1SAMPLE OUTPUT aaaaaaaaaabbbbbzzzzxTime Limit: 5.0 sec(s) for each input file.Memory Limit: 256 MBSource Limit: 1024 KBMarking Scheme: Score is assigned if any testcase passes.Allowed Languages: Bash, C, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java 8, JavaScript(Node.js), Julia, Kotlin, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, TypeScript, Visual Basic
Solution
To decompress a string, follow these steps:
- Accept a compressed string as input.
- Initialize an empty string to store the decompressed string.
- Iterate through each character in the compressed string.
- If the current character is a letter, append it to the decompressed string.
- If the current character is a number, convert it to an integer.
- Repeat the next character in the compressed string the number of times specified by the integer.
- Continue iterating until the end of the compressed string is reached.
- Print the decompressed string as the output.
Similar Questions
Compress the sequence 1111444433332222111 using Run-length encoding.
Compress the sequence 98700000000000000 using Simple Repetition Suppression(use f for flag).
Max Score: 20Given a string S and a character C, check whether the character C is occurring together in the string S.Input FormatThe first and only line of input contains a string S and character, C separated by space.Output FormatPrint "Yes" if the character C is occurring together, otherwise print "No".Constraints1 <= |S| <= 103ExampleInputsnooze oOutputYes
Nth Fibonacci NumberMax. score: 30Input format :An integerOutput format :An integerConstraints :1<=N<=1000000SAMPLE INPUT 10SAMPLE OUTPUT 89Time Limit: 5.0 sec(s) for each input file.Memory Limit: 256 MBSource Limit: 1024 KBMarking Scheme: Score is assigned if any testcase passes.Allowed Languages: C
Question9Max. score: 30.00Nth Fibonacci NumberInput format :An integerOutput format :An integerConstraints :1<=N<=1000000Sample input10Sample output89Note:Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement.LimitsTime Limit: 5.0 sec(s) for each input fileMemory Limit: 256 MBSource Limit: 1024 KBScoringScore is assigned if any testcase passesAllowed LanguagesC
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.