description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = int(input()) for i in range(0, t): str = input() temp = 0 maximum = 0 j = 0 test = 0 if str[0] == ">" or str[0] == "<": test = 1 for i in range(0, len(str)): if str[i] == "=": continue elif str[i] == str[j] and i != 0: temp += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR VAR VAR VAR NUMBER...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for t in range(int(input())): s = input() l = 0 g = 0 e = 0 maxl = 0 maxg = 0 i = 0 j = 0 length = len(s) for x in range(length): if s[x] == "=": e += 1 elif s[x] == "<": l += 1 i += 1 j = 0 if maxl < i: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NU...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = int(input()) for z in range(t): p, q = 1, 0 s = [] a = input() for i in a: if i != "=": s.append(i) n = len(s) if n == 1: print(2) continue for i in range(n - 1): if s[i] == s[i + 1]: p += 1 else: p = 1 q...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR N...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for t in range(int(input())): s = input().replace("=", "") a = s.split(">") + s.split("<") a = list(filter(lambda x: x != "", a)) l = 0 for i in a: l = max(l, len(i)) print(l + 1)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR STRING VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR ...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
tc = int(input()) while tc: str = input() l = len(str) tl = l pre = str[0] cnt = 1 max = 0 flag = 0 for x in range(1, l): if str[x] != "=": flag = 1 cur = str[x] if cur == pre: cnt += 1 else: if max <...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR ASSIG...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for _ in range(int(input())): line = input() line = line.replace("=", "") values = list(line) result = 0 answer = 0 if len(values) == 0: print(1) else: for i in range(1, len(values)): if values[i] == values[i - 1]: answer = answer + 1 e...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN ...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
test = int(input()) while test != 0: abc = input() abc = abc.replace("=", "") maxi = 0 count = 0 count1 = 0 for i in abc: if i == abc[0]: count = count + 1 count1 = 0 else: count1 = count1 + 1 count = 0 maxi = max(count, cou...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL V...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for x in range(int(input())): s = input() maxx = 0 a, b = 0, 0 for i in range(len(s)): if s[i] == "<": a += 1 b = 0 if a > maxx: maxx = a elif s[i] == ">": b += 1 a = 0 if b > maxx: ma...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CA...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for i in range(int(input())): str1 = input() leftbrack, rightbrack, count = 0, 0, 0 for _ in range(0, len(str1)): if str1[_] == "<": leftbrack, rightbrack = leftbrack + 1, 0 if leftbrack > count: count = leftbrack elif str1[_] == ">": right...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIG...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for _ in range(int(input())): s = input() ans = 0 last = "?" curr = 0 for ch in s: if ch == "=": continue if ch != last: ans = max(ans, curr) curr = 1 last = ch else: curr += 1 ans = max(ans, curr) print(ans ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = int(input()) for i in range(t): a = input() temp = 0 ans = 0 b = a.replace("=", "") for j in range(len(b)): if b[j] == "<": temp += 1 else: temp = 0 ans = max(ans, temp) temp = 0 for j in range(len(b)): if b[j] == ">": t...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
casos = int(input()) while casos > 0: signos = input() maximo = 1 largo = len(signos) i = 0 while i < largo: if signos[i] != "=": necesito = 0 j = i while j < largo: if signos[i] != signos[j] and signos[j] != "=": break ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR IF VAR VAR VAR VAR VAR VAR STRING IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VA...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = int(input()) for i in range(t): line = input() line = line.replace("=", "") max_seq = 1 curr_seq = 1 try: pre = line[0] except: print(1) continue for curr in line[1:]: if curr == pre: curr_seq += 1 else: max_seq = max(max_se...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = int(input().strip()) for _ in range(t): numList = [] less, great, maxVal = 0, 0, 0 sign = list(input().strip()) for iter in sign: if iter == "<": great = 0 less = less + 1 if less > maxVal: maxVal = less elif iter == ">": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR IF VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR STRING ASSIGN VAR NUMBER ASSIGN VA...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
def main(): t = eval(input()) while t != 0: str = input() Cur1 = 0 Cur2 = 0 Max = 0 for i in str: if i == "<": Cur1 = Cur1 + 1 if Cur2 != 0: Cur2 = 0 elif i == ">": Cur2 = Cur2 + 1...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUN...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = input() l = [] j = 0 lenm = lenb = 0 mas = [] dlina = 0 for i in range(int(t)): stroka = input() n = len(stroka) while j < n and stroka[j] == "=": j = j + 1 if j != n: curr = stroka[j] for c in stroka[j:]: if c == curr: mas.append(c) ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR FOR VAR VAR VAR IF VAR ...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for x in range(0, int(input())): s = input() s = s.replace("=", "") res, b, l, count = 0, 0, len(s), 0 if l > 0: while b < l: curr = s[b] b += 1 count = 1 while b < l and s[b] == curr: count += 1 b += 1 r...
FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR VAR VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FU...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for _ in range(int(input())): l = list(input()) temp = ["<", "="] fg, c = 0, 0 ans1, ans2 = 0, 0 for i in range(len(l)): if l[i] in temp: fg = 1 if l[i] == "<": c += 1 elif fg == 1: ans1 = max(ans1, c) fg = 0 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VA...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = int(input()) for i in range(t): s = input() m = 0 c = 0 j = 0 while j < len(s): if s[j : j + 1] == "=": j = j + 1 continue c = 0 if s[j : j + 1] == "<": while s[j : j + 1] != ">" and j < len(s): if s[j : j + 1] == "=": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER STRING WHILE VAR VAR BIN_OP VAR NUMB...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
def solution(): s = input() last_char = "-" P = 0 temp = 0 for i in range(0, len(s)): if s[i] == "=": continue if last_char == s[i]: temp = temp + 1 else: P = max(temp, P) temp = 1 last_char = s[i] P = max(temp, P) ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR B...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
o = int(input()) for h in range(0, o): s1 = input() if s1.count("=") == len(s1): print(1) else: s = "" for j in s1: if j != "=": s = s + j s = s + "a" max = 1 while len(s) != 1: i = s.find("<") j = s.find(">"...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN ...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for _ in range(int(input())): s = input() l = len(s) s1, s2 = [0] * l, [0] * l if s[0] == ">": s1[0] = 1 elif s[0] == "<": s2[0] = 1 for i in range(1, l): if s[i] == ">": if s[i - 1] == ">" or s[i - 1] == "=": s1[i] = s1[i - 1] + 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR IF VAR NUMBER STRING ASSIGN VAR NUMBER NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF VAR BIN_O...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
def count(_str): min = 1 max = 1 val = 1 for i in range(len(_str)): if _str[i] == "<": val += 1 elif _str[i] == ">": val -= 1 if val > max: max = val elif val < min: min = val print("min={0} max={1}".format(min, max)) ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR VAR RETURN BIN_OP BIN_OP VAR VAR NUMBER CLASS_DEF FUNC_DEF ASSIGN V...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
T = int(input()) for _ in range(T): ipStr = input() maxValue = 0 currentCh = "<" currentValue = 0 for ch in ipStr: if ch == "=": continue elif ch == currentCh: currentValue += 1 else: currentValue = 1 currentCh = ch if c...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
T = int(input()) for i in range(T): x = input().replace("=", "") max_right = 0 max_left = 0 curr_right = 0 curr_left = 0 right = False left = False for j in x: if j == ">": curr_right += 1 if not right: right = True if left: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER IF VAR VAR ...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
from itertools import groupby test = int(input()) for i in range(test): signs = list(input()) Signs = [j for j in signs if j != "="] if Signs.count("=") == len(Signs): print("1") else: consecutiveList = [sum(1 for l in g) for k, g in groupby(Signs)] print(max(consecutiveList) + ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR STRING IF FUNC_CALL VAR STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMB...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = int(input()) for i in range(t): s = input() count, temp, less, great, equals = 0, 0, 0, 0, 0 for j in range(0, len(s)): if s[j] == "<": less += 1 great = 0 if count <= less: count = less + 1 elif s[j] == ">": great += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIG...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
import itertools for test in range(int(input())): a = input() c = 0 m = a.count("=") if m == len(a): c = 1 print("1") if c == 0: n = a.replace("=", "") l = list(n) z = [(x[0], len(list(x[1]))) for x in itertools.groupby(l)] print(max(z, key=lambda x: ...
IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR F...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for i in range(int(input())): st = input() a = "<" b = ">" c = "=" j = 0 count = 1 list2 = [x for x in st if x != "="] if len(list2) == 0: print(1) else: list1 = [] while j < len(list2) - 1: if list2[j] == list2[j + 1]: count += 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR VAR STRING IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VA...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for _ in range(int(input())): srng = str(input()) srng = srng.replace("=", "") c1 = 0 c2 = 0 mx = 0 for a in srng: if a == ">": c1 += 1 c2 = 0 if c1 > mx: mx = c1 elif a == "<": c2 += 1 c1 = 0 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASS...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = int(input()) for _ in range(t): st = input() st = st.replace("=", "") if len(st) > 0: ans = 0 temp = 1 for i in range(1, len(st)): if st[i] == st[i - 1]: temp += 1 else: ans = max(ans, temp + 1) temp = 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING STRING IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP ...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
def solve(s): temp = [] for c in s: if c != "=": temp.append(c) count = 1 ans = 1 if temp: for i in range(1, len(temp)): if temp[i] == temp[i - 1]: count += 1 else: ans = max(ans, count) count = 1 ...
FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VA...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for _ in range(int(input())): st = input().replace("=", "") if not len(st): print(1) else: cu = mx = 1 for j in range(1, len(st)): if st[j] == st[j - 1]: cu += 1 else: mx = max(mx, cu) cu = 1 print(max(mx...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING STRING IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = int(input()) for a0 in range(t): n = input() gis = [] g1 = 0 l1 = 0 z = n.replace("=", "") for a1 in z: if a1 == ">": g1 += 1 else: gis.append(g1) g1 = 0 gis.append(g1) for a2 in z: if a2 == "<": l1 += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING STRING FOR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR IF VAR STRING VAR NUMBER E...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
def solve(sign): k = 0 minVal = k maxVal = k n = len(sign) for i in range(n): if sign[i] == ">": k = k - 1 if sign[i] == "<": k = k + 1 minVal = min(minVal, k) maxVal = max(maxVal, k) kVal = -1 * minVal + 1 p = kVal + maxVal return ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIG...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for i in range(int(input())): s = input() req = -1 con = 1 i = 1 prev = s[0] while i < len(s): if s[i] == "=": pass elif s[i] == prev: con += 1 else: if con > req: req = con con = 1 prev = s[i] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR V...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for _ in range(int(input())): q = input() x = 0 o = 0 y = "=" + q z = -1 c = -1 for i in range(1, len(y)): if y[i] == ">" and (y[i - 1] == "=" or y[i - 1] == ">"): x += 1 elif y[i] == "<" and (y[i - 1] == "=" or y[i - 1] == "<"): o += 1 else: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER STRING VAR BIN_OP VAR NUMBER STRING VAR NUMBER IF VAR VAR...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = int(input()) i = 0 while i < t: sum = 0 st = input() st = st.replace("=", "") l = len(st) j = 0 max = 0 if l == 0: print(1) else: while j < l - 1: if st[j] == st[j + 1]: sum += 1 else: sum = 0 if sum ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER V...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for t in range(int(input())): s = input() ans = count = 0 last = s[0] for c in s: if c == "=": continue if c == last: count += 1 else: ans = max(ans, count) count = 1 last = c print(max(ans, count) + 1)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for i in range(int(input())): s = input() z = [] l = g = 1 for j in s: if j == "<": g = g + 1 z.append(l) l = 1 elif j == ">": l = l + 1 z.append(g) g = 1 z.append(l) z.append(g) print(max(z))
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR STRING ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for _ in range(int(input())): s = input() p = "=" c = 1 ans = 1 for i in range(len(s)): if s[i] == "=": continue if s[i] == p: c += 1 else: c = 1 if c + 1 > ans: ans = c + 1 p = s[i] print(ans)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL V...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
test = int(input()) while test: st = input() mx = freq = 0 st += "0" l = len(st) p = "=" for i in range(0, l - 1): if st[i] == "=": continue elif (st[i] == "<" or st[i] == ">") and freq == 0: freq += 1 p = st[i] elif p == st[i]: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING IF VAR VAR STRING VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR VAR VAR NUMBER I...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = int(input()) for z in range(t): s = input() j = 1 ans = 1 a = [] for i in s: if i != "=": a.append(i) if len(a) == 0: print(1) continue for i in range(len(a) - 1): if a[i] == a[i + 1]: j += 1 ans = max(ans, j) el...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = int(input()) for i in range(t): s = input() l = len(s) flag = 0 cnt = 0 mx = 0 for j in range(l): if flag == 1: if s[j] == "<": cnt += 1 elif s[j] == ">": mx = max(mx, cnt) cnt = 1 flag = 2 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VA...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
n = int(input()) for i in range(0, n): text = input() m = len(text) maxnum1 = num1 = 1 for i in range(0, m): if text[i] == "<": num1 = num1 + 1 elif text[i] == ">": if num1 > maxnum1: maxnum1 = num1 num1 = 1 if num1 > maxnum1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSI...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = int(input()) for I in range(t): s = input().rstrip("\r") count1 = 1 flag1 = 0 flag2 = 0 max1 = 1 for i in range(len(s)): if s[i] == "<": flag1 = 1 if flag2 == 1: count1 = 1 flag2 = 0 count1 += 1 if count1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF V...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = int(input()) for _ in range(t): seq = list(input()) counter = 0 maximum = 0 Greaterthan = False for i in seq: if i == "<": if Greaterthan: counter += 1 else: if counter > maximum: maximum = counter ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR STRING IF VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VA...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
N = int(input()) z = 0 while z < N: z += 1 st = input() i = 0 maxi = 0 s1 = s2 = 0 while i < len(st): if st[i] is "<": s1 += 1 s2 = 0 if st[i] is ">": s2 += 1 s1 = 0 if max(s1, s2) > maxi: maxi = max(s1, s2) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR ASSI...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
t = int(input()) while t > 0: s = input() s = s.replace("=", "") i, j, m = 0, 0, 0 while i < len(s): j = i while j < len(s) and s[j] == s[i]: j += 1 m = max(m, j - i) i = j print(m + 1) t -= 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR EXP...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for _ in range(int(input())): s = list("".join(input().split("="))) n = 1 m = 0 i = 0 if s == []: m = 1 while i < len(s): if s[i] == "<": n += 1 if n > m: m = n elif s[i] == ">": if i + 1 < len(s) and s[i + 1] != ">": ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR VAR STRING IF BIN_OP VA...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
for j in range(int(input())): count = 0 ns = "" str1 = "" str1 = input() count1 = 0 max1 = 0 max2 = 0 for i in range(len(str1)): if str1[i] == "=": continue ns += str1[i] for k in range(len(ns)): if ns[k] == "<": count1 = 0 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VA...
Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and t...
n = int(input()) for i in range(n): k = 0 n1 = 0 p = 0 q = 0 lis = input() for j in lis: if j == "<": if k == 1: n1 += 1 if n1 > p: p = n1 else: n1 = 0 n1 += 1 if n...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR STRING IF VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR S...
Read problems statements in Mandarin Chinese and Russian as well. Given a sequence of n distinct numbers a[1..n], we want to sort them in an ascending order. An interesting property of some sequences is that all numbers are almost at their correct position! More formally, the distance between the current position of...
for i in range(int(input())): n = int(input()) a = list(map(int, input().split())) flag = 0 for j in range(n - 2): if a[j] > a[j + 1] and a[j] > a[j + 2]: print("NO") flag = 1 break if flag == 0: print("YES")
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER...
Read problems statements in Mandarin Chinese and Russian as well. Given a sequence of n distinct numbers a[1..n], we want to sort them in an ascending order. An interesting property of some sequences is that all numbers are almost at their correct position! More formally, the distance between the current position of...
t = int(input()) for _ in range(t): n = int(input()) l = [int(x) for x in input().split()] flag = True for i in range(n - 2): if l[i] > l[i + 2]: flag = False break if flag: print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VA...
Read problems statements in Mandarin Chinese and Russian as well. Given a sequence of n distinct numbers a[1..n], we want to sort them in an ascending order. An interesting property of some sequences is that all numbers are almost at their correct position! More formally, the distance between the current position of...
def sorting(n, lst): count = 0 for i in range(n - 2): if lst[i] > lst[i + 1] and lst[i] > lst[i + 2]: count = 1 return "NO" if count == 0: return "YES" t = int(input()) for i in range(t): n = int(input()) lst = list(map(int, input().strip().split()))[:n] ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER RETURN STRING IF VAR NUMBER RETURN STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR F...
Read problems statements in Mandarin Chinese and Russian as well. Given a sequence of n distinct numbers a[1..n], we want to sort them in an ascending order. An interesting property of some sequences is that all numbers are almost at their correct position! More formally, the distance between the current position of...
t = int(input()) for _ in range(t): input() arr = [int(x) for x in input().strip().split()] flag = 0 result = "YES" for i in range(1, len(arr)): if arr[i - 1] > arr[i]: if flag == 1: result = "NO" break arr[i - 1], arr[i] = arr[i], arr[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR IF VAR NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR...
Read problems statements in Mandarin Chinese and Russian as well. Given a sequence of n distinct numbers a[1..n], we want to sort them in an ascending order. An interesting property of some sequences is that all numbers are almost at their correct position! More formally, the distance between the current position of...
def Test(n, arr): last = arr[n - 1] flag = 0 for i in range(n - 2): if arr[i] > arr[i + 1] and arr[i] > arr[i + 2]: return "NO" return "YES" for _ in range(int(input())): n = int(input()) s = list(map(int, input().split())) print(Test(n, s))
FUNC_DEF ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER RETURN STRING RETURN STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR V...
Read problems statements in Mandarin Chinese and Russian as well. Given a sequence of n distinct numbers a[1..n], we want to sort them in an ascending order. An interesting property of some sequences is that all numbers are almost at their correct position! More formally, the distance between the current position of...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) if n < 3: print("YES") else: f = 0 for i in range(n - 2): if a[i] > a[i + 1] and a[i] > a[i + 2]: f = 1 break if f == 0: print("YES")...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASS...
Read problems statements in Mandarin Chinese and Russian as well. Given a sequence of n distinct numbers a[1..n], we want to sort them in an ascending order. An interesting property of some sequences is that all numbers are almost at their correct position! More formally, the distance between the current position of...
def solve(): n = int(input()) s = list(map(int, input().strip().split()))[:n] for i in range(n - 2): if s[i] > s[i + 1] and s[i] > s[i + 2]: return "NO" return "YES" for _ in range(int(input())): print(solve())
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER RETURN STRING RETURN STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): l = [] n = len(s) if n == 1: return s i = 0 k = -1 while i < n: if k == -1: l.append(s[i]) k += 1 else: t = l[k] if t == s[i]:...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBE...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): i = 1 while i < len(s): if i == 0: i += 1 continue if s[i] == s[i - 1]: s = s[: i - 1] + s[i + 1 :] i -= 1 else: i += 1 if len(s) == 0...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): lexp = list(s) stack = [] out = [] n = len(lexp) top = 0 stack.append(lexp[0]) for i in range(1, n): if len(stack) > 0: if lexp[i] != stack[top]: top += 1 ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUM...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): i = 0 s = s + "." ans = ["" for i in range(len(s))] ans1 = 0 while i < len(s) - 1: if s[i] == s[i + 1]: i += 2 else: ans[ans1] = s[i] ans1 += 1 if...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR STRING VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): l = [] for i in s: if len(l) == 0: l.append(i) elif l[-1] == i: l.pop() else: l.append(i) if len(l) == 0: return -1 else: return "".jo...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN FUNC_CALL STRING VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): st = [] for i in s: if st and st[-1] == i: st.pop() else: st.append(i) res = "".join(st) if not res: return -1 return res
CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR IF VAR RETURN NUMBER RETURN VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): l = [] for i in s: if not l: l.append(i) elif l[-1] == i: l.pop() else: l.append(i) new = "".join(l) return new if new != "" else -1
CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR RETURN VAR STRING VAR NUMBER
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): stack = [] i = 0 while i < len(s): if len(stack) == 0: stack.append(s[i]) elif s[i] == stack[-1]: stack.pop() else: stack.append(s[i]) i += 1 ans ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR STRING WHILE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR STRING RETURN NUMBE...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): stack = [] for i in s: if len(stack) == 0: stack.append(i) elif stack[-1] == i: stack.pop(-1) else: stack.append(i) ans = "" for i in stack: ans +...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR VAR VAR VAR IF VAR STRING RETURN NUMBER RETURN VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): i = 0 a = list(s) c = len(a) s1 = "" j = 0 while i < c: if j == 0: s1 += s[i] j += 1 i += 1 else: s1 += s[i] j += 1 ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR VAR IF VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR VAR BIN_OP FUN...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): stk = [] i = 0 ans = "" while i < len(s): if len(stk) == 0: stk.append(s[i]) i += 1 elif stk[-1] == s[i]: while len(stk) > 0 and i < len(s) and stk[-1] == s[i]: ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR STRING WHILE VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR VAR WHILE FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR EXPR F...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): stack = [] i = 0 while i < len(s): if len(stack) > 0 and stack[-1] == s[i]: stack.pop() i += 1 else: stack.append(s[i]) i += 1 if len(stack) == 0: ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN FUNC_CALL STRING VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): n = len(s) ans, i = [s[0]], 1 while i < len(s): if len(ans) > 0: if s[i] == ans[-1]: ans.pop() n -= 2 else: ans.append(s[i]) else: ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN FUNC_CALL STRING VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): stack = [] for ele in s: if len(stack) > 0: t = stack.pop() if t == ele: continue else: stack.append(t) stack.append(ele) else...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR LIST RETURN STRING RETURN FUNC_CALL STRING VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): stack = [] top = -1 for i in range(0, len(s)): if len(stack) == 0: stack.append(s[i]) top += 1 elif stack[top] != s[i]: stack.append(s[i]) top += 1 el...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN FUNC_CALL STRING V...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
import sys sys.setrecursionlimit(10**6) class Solution: def removePair(self, s): def solve(s): if len(s) == 0: return "" if len(s) == 1: return s if s[0] == s[1]: return solve(s[2:]) else: sm...
IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER CLASS_DEF FUNC_DEF FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN STRING IF FUNC_CALL VAR VAR NUMBER RETURN VAR IF VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER RETURN VAR NUMBER RETURN BIN_OP VAR NUMBER...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): l = [] for i in range(len(s)): if l and l[-1] == s[i]: l.pop() else: l.append(s[i]) if l: return "".join(l) else: return "-1"
CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR IF VAR RETURN FUNC_CALL STRING VAR RETURN STRING
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): temp = [] for x in s[:]: if temp: if temp[-1] == x: temp.pop() else: temp.append(x) else: temp.append(x) return "".join(temp) if temp else...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR FUNC_CALL STRING VAR NUMBER
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): arr = [] for i in s: if arr and arr[-1] == i: arr.pop() else: arr.append(i) return "".join(arr) if arr else "-1"
CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR RETURN VAR FUNC_CALL STRING VAR STRING
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): stack = [] stack.append(s[0]) curr_index = 1 while curr_index < len(s): if len(stack) == 0: stack.append(s[curr_index]) elif s[curr_index] == stack[-1]: stack.pop() else: ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR STRING FOR VAR VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VA...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): stk = [] for char in s: if not stk: stk.append(char) continue if stk[-1] == char: stk.pop() else: stk.append(char) if not stk: return -1 ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR IF VAR RETURN NUMBER RETURN FUNC_CALL STRING VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): i = 1 s = list(s) A = [s[0]] for i in range(1, len(s)): if len(A) == 0: A.append(s[i]) elif s[i] == A[-1]: A.pop() else: A.append(s[i]) if len(A) == 0...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN FUNC_CAL...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): flag = False while flag == False: for i in range(1, len(s)): if s[i - 1] == s[i]: s = s.replace(s[i - 1] + s[i], "") flag = True break if flag == True: ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR RETURN VAR RETURN NUMBER
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): stack = [] for i in range(len(s)): if not stack: stack.append(s[i]) elif stack and s[i] == stack[-1]: stack.pop() else: stack.append(s[i]) return "".join(stack) if st...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_CALL STRING VAR NUMBER
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): stack = [] for i in s: if stack and stack[-1] == i: stack.pop() else: stack.append(i) c = "" if not stack: return -1 while stack: c += stack.pop() ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING IF VAR RETURN NUMBER WHILE VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER RETURN VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
def merge(s1, s2): while s1 and s2: if s1[-1] == s2[0]: s1.pop(-1) s2.pop(0) else: break return s1 + s2 def break_pair(s): if len(s) == 1: return s else: mid = len(s) // 2 s1 = break_pair(s[:mid]) s2 = break_pair(s[mid...
FUNC_DEF WHILE VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN BIN_OP VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN V...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): stk = [-1] top = 0 for i in s: if stk[top] == i: stk.pop(top) top -= 1 else: top += 1 stk.append(i) if len(stk) == 1: return -1 else: ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR RETURN VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): i = 0 while i < len(s) - 1: if s[i] == s[i + 1]: s = s[:i] + s[i + 2 :] i = -1 i += 1 if len(s) == 0: return "-1" return s
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN STRING RETURN VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): stack = [] n = len(s) count = 0 for i in range(n): if stack == []: stack = [s[i]] count += 1 elif stack[-1] == s[i]: stack.pop() count -= 1 ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR LIST ASSIGN VAR LIST VAR VAR VAR NUMBER IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): fg = [] res = "" for i in s: f = 0 while len(fg) > 0 and fg[len(fg) - 1] == i: fg.pop(len(fg) - 1) f = 1 if f == 0: fg.append(i) while len(fg) > 0: ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR STRING FOR VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP ...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): lst = [] lst.append("@") for i in s: if lst[len(lst) - 1] != i: lst.append(i) else: lst.pop() if len(lst) == 1: return -1 kk = "" for i in range(1, len(lst)):...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST EXPR FUNC_CALL VAR STRING FOR VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): s1 = s while True: isRemoved = False for idx in range(len(s) - 1): if s[idx] == s[idx + 1]: text2Remove = s[idx] + s[idx + 1] s1 = s1.replace(text2Remove, "", 1) ...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR WHILE NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR IF FUNC_CALL VAR VAR NUMBER RE...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): i = 0 s = list(s) while i < len(s) - 1 and len(s) != 0: if s[i] == s[i + 1]: s.pop(i) s.pop(i) i = -1 i += 1 if len(s) == 0: return "-1" return "".joi...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN STRING RETURN FUNC_CALL STRING VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): l = [] for i in s: if not l: l.append(i) elif l[len(l) - 1] == i: l.pop() else: l.append(i) k = "" if not l: return -1 for i in l: ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR EXPR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING IF VAR RETURN NUMBER FOR VAR VAR VAR VAR RETURN VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): stack = [" "] * len(s) top = -1 for x in s: if top == -1 or stack[top] != x: top += 1 stack[top] = x elif x == stack[top]: top -= 1 s = "" for i in range(0, top +...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF VAR NUMBER RETURN NUMBER RETURN VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): st = [] i = 0 while i < len(s): if len(st) == 0 or st[-1] != s[i]: st.append(s[i]) elif len(st) != 0 and st[-1] == s[i]: st.pop() i += 1 t = "" for j in st: ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING FOR VAR VAR VAR VAR IF VAR STRING RETURN NUMBER RETURN VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): ans = "" st = ["0", s[0]] l = len(s) for i in range(1, l): if st[-1] == s[i]: st.pop() flag = True else: st.append(s[i]) if st != ["0"]: ans = "".join...
CLASS_DEF FUNC_DEF ASSIGN VAR STRING ASSIGN VAR LIST STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR LIST STRING ASSIGN VAR FUNC_CALL STRING VAR NUMBER ASSIGN VAR NUMBER RETURN VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): l = [] l.append(s[0]) for i in range(1, len(s)): try: if l[-1] == s[i]: l.pop() else: l.append(s[i]) except IndexError: l.append(s[i]) ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN FUNC_CALL STRING VAR
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): i = 0 ans = "" while i < len(s): if i + 1 >= len(s): if s: return s else: return -1 if s[i + 1] == s[i]: count = 0 temp = ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR STRING WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR RETURN VAR RETURN NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBE...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): new_s = [] l = 0 b = -1 while l < len(s) - 1: if s[l] == s[l + 1]: l += 2 elif b != -1 and s[l] == new_s[b]: new_s.pop() b -= 1 l += 1 else: ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR ...
Our geek loves to play with strings, Currently, he is trying to reduce the size of a string by recursively removing all the consecutive duplicate pairs. In other words, He can apply the below operations any number of times. Remove all the consecutive duplicate pairs and concatenate the remaining string to replace the ...
class Solution: def removePair(self, s): st = [] i = 0 while i < len(s): if len(st) == 0 or s[i] != st[-1]: st.append(s[i]) i += 1 else: st.pop() i += 1 else: short_string = "" ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN VAR