Answers for "You are given a string S. Suppose a character ‘c’ occurs consecutively X times in the string. Replace these consecutive occurrences of the character ‘c’ with (X, c) in string"

0

You are given a string S. Suppose a character ‘c’ occurs consecutively X times in the string. Replace these consecutive occurrences of the character ‘c’ with (X, c) in string

(1, 1) (3, 2) (1, 3) (2, 1)
Posted by: Guest on January-30-2021
0

You are given a string S. Suppose a character ‘c’ occurs consecutively X times in the string. Replace these consecutive occurrences of the character ‘c’ with (X, c) in string

from itertools import *

for i,j in groupby(map(int,list(raw_input()))):
    print(tuple([len(list(j)), i]) ,end = " ")
Posted by: Guest on October-10-2021

Code answers related to "You are given a string S. Suppose a character ‘c’ occurs consecutively X times in the string. Replace these consecutive occurrences of the character ‘c’ with (X, c) in string"

Python Answers by Framework

Browse Popular Code Answers by Language