message
stringlengths
2
23.8k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
97
109k
cluster
float64
0
0
__index_level_0__
int64
194
217k
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters. In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string s_j (j may be equal to i). You may perform this...
instruction
0
42,267
0
84,534
Tags: greedy, strings Correct Solution: ``` t=int(input()) for i in range(t): n=int(input()) a=[] for i in range(n): s=input() a.append(s) d={} for i in range(len(a)): for j in range(len(a[i])): if a[i][j] in d: d[a[i][j]]+=1 e...
output
1
42,267
0
84,535
Provide tags and a correct Python 3 solution for this coding contest problem. You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters. In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string s_j (j may be equal to i). You may perform this...
instruction
0
42,268
0
84,536
Tags: greedy, strings Correct Solution: ``` from collections import Counter def solve(p,n): for j in p: if p[j]%n!=0:return 'NO' return 'YES' for j in range(int(input())): n=int(input()) ans="" for i in range(n): ans+=input() p=Counter(ans) print(solve(p,n)) ```
output
1
42,268
0
84,537
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters. In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string ...
instruction
0
42,269
0
84,538
Yes
output
1
42,269
0
84,539
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters. In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string ...
instruction
0
42,270
0
84,540
Yes
output
1
42,270
0
84,541
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters. In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string ...
instruction
0
42,271
0
84,542
Yes
output
1
42,271
0
84,543
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters. In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string ...
instruction
0
42,272
0
84,544
Yes
output
1
42,272
0
84,545
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters. In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string ...
instruction
0
42,273
0
84,546
No
output
1
42,273
0
84,547
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters. In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string ...
instruction
0
42,274
0
84,548
No
output
1
42,274
0
84,549
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters. In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string ...
instruction
0
42,275
0
84,550
No
output
1
42,275
0
84,551
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters. In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string ...
instruction
0
42,276
0
84,552
No
output
1
42,276
0
84,553
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each...
instruction
0
42,540
0
85,080
Tags: constructive algorithms, greedy, implementation, strings Correct Solution: ``` s = input() t = [] i = 0 while i < len(s) and s[i] == "a": if i == len(s) - 1: t.append("z") else: t.append("a") i += 1 while i < len(s) and s[i] != "a": t.append(chr(ord(s[i]) - 1)) i += 1 t += list...
output
1
42,540
0
85,081
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each...
instruction
0
42,541
0
85,082
Tags: constructive algorithms, greedy, implementation, strings Correct Solution: ``` ori_str = input(); res = ''; n = len(ori_str); for i in range(n): if ori_str[i] != 'a': break; else: if i == n - 1: res = res + 'z'; else: res = res + 'a'; for i in range(len(re...
output
1
42,541
0
85,083
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each...
instruction
0
42,542
0
85,084
Tags: constructive algorithms, greedy, implementation, strings Correct Solution: ``` def move(s): new_s = '' for i in range(len(s)): new_s += chr(ord(s[i]) - 1) return new_s s = input() st = -1 fi = -1 for i in range(len(s)): if st == -1 and s[i] != 'a': st = i elif st != -1 and s[...
output
1
42,542
0
85,085
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each...
instruction
0
42,543
0
85,086
Tags: constructive algorithms, greedy, implementation, strings Correct Solution: ``` import string alphabet = string.ascii_lowercase di = {} for i in range(len(alphabet)): di[alphabet[i]] = alphabet[(i - 1) % len(alphabet)] s = input() new_s = "" was_a = False ans = False for element in s: if element == "a"...
output
1
42,543
0
85,087
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each...
instruction
0
42,544
0
85,088
Tags: constructive algorithms, greedy, implementation, strings Correct Solution: ``` # import sys # input=sys.stdin.readline a=input() a="a"+a+"a" a=list(a) b=[] for i in range(len(a)): if a[i]=="a": b.append(i) e=0 for i in range(len(b)-1): if b[i]+1!=b[i+1]: e=1 f=b[i] g=b[i+1...
output
1
42,544
0
85,089
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each...
instruction
0
42,545
0
85,090
Tags: constructive algorithms, greedy, implementation, strings Correct Solution: ``` s = input() s1 = '' start = False metka = False i = 0 while i < len(s) and not start: if s[i] != 'a' and not start: s1 += chr(ord(s[i])- 1) metka = True elif s[i] == 'a' and not metka: s1 += s[i] el...
output
1
42,545
0
85,091
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each...
instruction
0
42,546
0
85,092
Tags: constructive algorithms, greedy, implementation, strings Correct Solution: ``` n = input() i = 0 while(i < len(n)): if(n[i] == 'a'): i += 1 else: break if(i == len(n)): print(n[:i-1]+'z') else: j = i while(j < len(n)): if(n[j] != 'a'): j += 1 else: ...
output
1
42,546
0
85,093
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each...
instruction
0
42,547
0
85,094
Tags: constructive algorithms, greedy, implementation, strings Correct Solution: ``` s = list(input()) dic = {} for i in range(1, 26): dic[chr(i + ord('a'))] = chr(i - 1 + ord('a')) dic['a'] = 'z' n = len(s) for i in range(n): if s[i] != 'a': j = i while j < n and s[j] != 'a': s[j] =...
output
1
42,547
0
85,095
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b...
instruction
0
42,548
0
85,096
Yes
output
1
42,548
0
85,097
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b...
instruction
0
42,549
0
85,098
Yes
output
1
42,549
0
85,099
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b...
instruction
0
42,550
0
85,100
Yes
output
1
42,550
0
85,101
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b...
instruction
0
42,551
0
85,102
Yes
output
1
42,551
0
85,103
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b...
instruction
0
42,552
0
85,104
No
output
1
42,552
0
85,105
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b...
instruction
0
42,553
0
85,106
No
output
1
42,553
0
85,107
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b...
instruction
0
42,554
0
85,108
No
output
1
42,554
0
85,109
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b...
instruction
0
42,555
0
85,110
No
output
1
42,555
0
85,111
Provide a correct Python 3 solution for this coding contest problem. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example, `aa` and `bubobubo` are good; an empty string, `a`, `a...
instruction
0
42,768
0
85,536
"Correct Solution: ``` if __name__ == "__main__": N = int(input()) n = 40 for i in range(40, -1, -1): if (N >= (1 << i) - 1): n = i break data = [] for i in range(n): data.append(i + 1) N -= (1 << n) - 1 tmp = n for i in range(n - 1, -1, -1): ...
output
1
42,768
0
85,537
Provide a correct Python 3 solution for this coding contest problem. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example, `aa` and `bubobubo` are good; an empty string, `a`, `a...
instruction
0
42,769
0
85,538
"Correct Solution: ``` def ncr(n, r): r = min(n - r, r) up = 1 down = 1 for i in range(r): up *= (n - i) down *= (i + 1) return up // down def seq(x): s = 0 for i in range(1, x): j = i * 2 if j > x: break s += ncr(x, j) return s def...
output
1
42,769
0
85,539
Provide a correct Python 3 solution for this coding contest problem. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example, `aa` and `bubobubo` are good; an empty string, `a`, `a...
instruction
0
42,770
0
85,540
"Correct Solution: ``` def f(n): if n == 1: return [] if n % 2 == 0: r = f(n//2) k = len(r) return r + [k+1] if n % 2 == 1: r = f(n - 1) k = len(r) return [k+1] + r n = int(input()) r = f(n+1) k = len(r) res = r + list(range(1, k+1)) print(len(res)) ...
output
1
42,770
0
85,541
Provide a correct Python 3 solution for this coding contest problem. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example, `aa` and `bubobubo` are good; an empty string, `a`, `a...
instruction
0
42,771
0
85,542
"Correct Solution: ``` #!/usr/bin/env python3 n = int(input()) x = [] y = [] k = 1 for c in bin(n + 1)[2 :][1 :]: x += [ k ] y += [ k ] k += 1 if int(c): x = [ k ] + x y += [ k ] k += 1 print(len(x + y)) print(*(x + y)) ```
output
1
42,771
0
85,543
Provide a correct Python 3 solution for this coding contest problem. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example, `aa` and `bubobubo` are good; an empty string, `a`, `a...
instruction
0
42,772
0
85,544
"Correct Solution: ``` def nCr(a,b): tmp=1 for i in range(a,a-b,-1):tmp*=i for i in range(1,b+1,1):tmp//=i return tmp n=int(input()) out=[] co=1 coo=0 while n>0: t=2 while True: sum1=0 for j in range(2,t+1,2): sum1+=nCr(t,j) # print(n,sum) if n<sum1: t-=1 # n-=rco break rco=sum1 t+=1 ad=[c...
output
1
42,772
0
85,545
Provide a correct Python 3 solution for this coding contest problem. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example, `aa` and `bubobubo` are good; an empty string, `a`, `a...
instruction
0
42,773
0
85,546
"Correct Solution: ``` n=int(input()) a=[0] for i in range(40): if n&(1<<i):a.append(i) ans=[] j=100 for i in range(len(a)-1): for _ in range(a[i+1]-a[i]): ans.append(j) j-=1 ans.append(i+1) ans=ans[:-1] ans=[50]+[100-i for i in range(a[-1])]+[i+1 for i in range(len(a)-2)][::-1]+ans+[50] print(len(ans)) p...
output
1
42,773
0
85,547
Provide a correct Python 3 solution for this coding contest problem. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example, `aa` and `bubobubo` are good; an empty string, `a`, `a...
instruction
0
42,774
0
85,548
"Correct Solution: ``` import sys input = sys.stdin.readline from collections import deque N = int(input()) # empty N += 1 bit = [i for i in range(60) if N&(1<<i)] n = bit[-1] left = deque(range(n,0,-1)) right = deque() x = n+1 for i in range(n,0,-1): right.append(i) if i-1 in bit: right.append(x)...
output
1
42,774
0
85,549
Provide a correct Python 3 solution for this coding contest problem. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example, `aa` and `bubobubo` are good; an empty string, `a`, `a...
instruction
0
42,775
0
85,550
"Correct Solution: ``` n = int(input()) + 1 k = 50 while ~n >> k & 1: k -= 1 k -= 1 a = [] b = [] now = 1 while k >= 0: a = a + [now] b = b + [now] now += 1 if n >> k & 1: a = a + [now] b = [now] + b now += 1 k -= 1 print(len(a + b)) print(*(a + b)) ```
output
1
42,775
0
85,551
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example...
instruction
0
42,776
0
85,552
Yes
output
1
42,776
0
85,553
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example...
instruction
0
42,777
0
85,554
Yes
output
1
42,777
0
85,555
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example...
instruction
0
42,778
0
85,556
Yes
output
1
42,778
0
85,557
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example...
instruction
0
42,779
0
85,558
Yes
output
1
42,779
0
85,559
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example...
instruction
0
42,780
0
85,560
No
output
1
42,780
0
85,561
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example...
instruction
0
42,781
0
85,562
No
output
1
42,781
0
85,563
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example...
instruction
0
42,782
0
85,564
No
output
1
42,782
0
85,565
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example...
instruction
0
42,783
0
85,566
No
output
1
42,783
0
85,567
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a binary string of length n (i. e. a string consisting of n characters '0' and '1'). In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the...
instruction
0
43,053
0
86,106
Tags: greedy Correct Solution: ``` q = int(input()) for i in range(q): n, k = map(int, input().split()) s = list(input()) min_pos = 0 for j in range(n): if s[j] == '0': p = max(j - k, min_pos) if k >= j - p: k -= j - p s[j], s[p] = s[p], s[...
output
1
43,053
0
86,107
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a binary string of length n (i. e. a string consisting of n characters '0' and '1'). In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the...
instruction
0
43,054
0
86,108
Tags: greedy Correct Solution: ``` from sys import stdin input = stdin.readline def solve(s, k): result = [] ones = 0 for char in s: if k == 0: break elif char == 1: ones += 1 elif k >= ones: result.append(0) k -= ones elif k...
output
1
43,054
0
86,109
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a binary string of length n (i. e. a string consisting of n characters '0' and '1'). In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the...
instruction
0
43,055
0
86,110
Tags: greedy Correct Solution: ``` import sys import math from collections import defaultdict,Counter,deque # input=sys.stdin.readline # def print(x): # sys.stdout.write(str(x)+"\n") import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file...
output
1
43,055
0
86,111
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a binary string of length n (i. e. a string consisting of n characters '0' and '1'). In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the...
instruction
0
43,056
0
86,112
Tags: greedy Correct Solution: ``` class Case: def __init__(self, size, moves, string): self.size = size self.moves = moves self.string = string SPACE = ' ' ZERO = '0' ONE = '1' def get_case(): line_elements = input().split(SPACE) size = int(line_elements[0]) moves = int(line...
output
1
43,056
0
86,113
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a binary string of length n (i. e. a string consisting of n characters '0' and '1'). In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the...
instruction
0
43,057
0
86,114
Tags: greedy Correct Solution: ``` for iter in range(int(input())): numbers = list(map(int, input().split())) a, b = numbers[0], numbers[1] string = input() counter = 0 ans = '' flag = 0 for i in range(a): if string[i] == '0': counter += 1 ans = ans + '0' ...
output
1
43,057
0
86,115
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a binary string of length n (i. e. a string consisting of n characters '0' and '1'). In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the...
instruction
0
43,058
0
86,116
Tags: greedy Correct Solution: ``` R = lambda: map(int, input().split()) for _ in range(int(input())): n,k = R() L = input() p = k c = 0 f = 1 for i in range(n): if L[i] == '0': if k >= (i-c):k -= (i-c) else:f = 0;break c += 1 if f:print('0'*c + '1...
output
1
43,058
0
86,117
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a binary string of length n (i. e. a string consisting of n characters '0' and '1'). In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the...
instruction
0
43,059
0
86,118
Tags: greedy Correct Solution: ``` N = int(input()) for _ in range(N): n,k = map(int,input().split()) a = [int(i) for i in input()] Z = [] for i,v in enumerate(a): if v == 0: Z.append(i) s = 0 rem = k for z in Z: if not rem: break if s == z: s += 1 continue mv = mi...
output
1
43,059
0
86,119
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a binary string of length n (i. e. a string consisting of n characters '0' and '1'). In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the...
instruction
0
43,060
0
86,120
Tags: greedy Correct Solution: ``` def solve(n,k,s): ind = [] flag = 0 #ind initialization for q in range(n): if s[q] == '0' and flag == 0: continue if s[q] == '1': flag = 1 if s[q] == '0' and flag == 1: ind.append(q+1) #edge case #11111 or 000000 if len(...
output
1
43,060
0
86,121