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.
- Prepare
- Algorithms
- Bit Manipulation
- Cipher
- Discussions
Cipher
Cipher
Sort by
recency
|
112 Discussions
|
Please Login in order to post a comment
def cipher(k, s): # Write your code here n=len(s) s1=s[0:n-k+1] res,xr="","0" for i1 in s1: if len(xr)-1
C++
Here is Cipher problem solution in Python Java c++ and c programming - https://programs.programmingoneonone.com/2021/07/hackerrank-cipher-problem-solution.html
Not a bad challenge! Took me some time and thoughts to solve it in O(n) time. The key here is to simply keep track of how many ones are in the last k characters of the original string.