Remove Consecutive Characters | InterviewBit | Solution
Note: If you want a detailed explanation, here you go: Remove Consecutive Characters | InterviewBit | Solution Explained.
class Solution: def solve(self, s, k): a = ["."] for c in s: if a[-1][0] == c: a[-1] += c else: a.append(str(c)) a = a[1:] ns = "" for temp in a: final_len = len(temp)%k ns += temp[0]*final_len return ns
Recommended Posts
Gas Station | InterviewBit | Solution Explained
June 13, 2022
Majority Element | InterviewBit | Solution Explained
June 13, 2022
Please write the proof.
This solution need an amendment for 2 digit number.
Please write a Proof for this