description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Given two numbers represented by two linked lists, write a function that returns Sum list. The sum list is linked list representation of addition of two input numbers.
Example 1:
Input:
S1 = 3, S2 = 3
ValueS1 = {2,3,4}
ValueS2 = {3,4,5}
Output: 5 7 9
Explanation: After adding the 2 numbers
the resultant number is 5 7 9... | def addSameSize(h1, h2, carry):
h1 = reverseList(h1)
h2 = reverseList(h2)
head = h1
while h1 != None:
value = h1.data + h2.data + carry.data
carry.data = value // 10
h1.data = value % 10
h1 = h1.next
h2 = h2.next
head = reverseList(head)
return head
def ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE VAR NONE ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN... |
Given two numbers represented by two linked lists, write a function that returns Sum list. The sum list is linked list representation of addition of two input numbers.
Example 1:
Input:
S1 = 3, S2 = 3
ValueS1 = {2,3,4}
ValueS2 = {3,4,5}
Output: 5 7 9
Explanation: After adding the 2 numbers
the resultant number is 5 7 9... | def addSameSize(h1, h2, carry):
def reverse(head):
prev = None
curr = head
next1 = None
while curr != None:
next1 = curr.next
curr.next = prev
prev = curr
curr = next1
return prev
h1 = reverse(h1)
h2 = reverse(h2)
... | FUNC_DEF FUNC_DEF ASSIGN VAR NONE ASSIGN VAR VAR ASSIGN VAR NONE WHILE VAR NONE ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NONE ASSIGN VAR NONE WHILE VAR NONE VAR NONE ASSIGN VAR BIN_OP BIN_OP ... |
Given two numbers represented by two linked lists, write a function that returns Sum list. The sum list is linked list representation of addition of two input numbers.
Example 1:
Input:
S1 = 3, S2 = 3
ValueS1 = {2,3,4}
ValueS2 = {3,4,5}
Output: 5 7 9
Explanation: After adding the 2 numbers
the resultant number is 5 7 9... | def addSameSize(h1, h2, carry):
num1 = 0
num2 = 0
while h1:
num1 = num1 * 10 + h1.data
h1 = h1.next
while h2:
num2 = num2 * 10 + h2.data
h2 = h2.next
res = num1 + num2
dummy = Node(res % 10)
res //= 10
while res != 0:
num = res % 10
p = Nod... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR WHILE VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CAL... |
Given two numbers represented by two linked lists, write a function that returns Sum list. The sum list is linked list representation of addition of two input numbers.
Example 1:
Input:
S1 = 3, S2 = 3
ValueS1 = {2,3,4}
ValueS2 = {3,4,5}
Output: 5 7 9
Explanation: After adding the 2 numbers
the resultant number is 5 7 9... | def addSameSize(h1, h2, carry):
if not h1:
return
sm = 0
result = Node(sm)
result.next = addSameSize(h1.next, h2.next, carry)
sm = h1.data + h2.data + carry.data
carry.data = sm // 10
sm = sm % 10
result.data = sm
return result
def addCarryToRemaining(h1, curr, result, carr... | FUNC_DEF IF VAR RETURN ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR ... |
Given two numbers represented by two linked lists, write a function that returns Sum list. The sum list is linked list representation of addition of two input numbers.
Example 1:
Input:
S1 = 3, S2 = 3
ValueS1 = {2,3,4}
ValueS2 = {3,4,5}
Output: 5 7 9
Explanation: After adding the 2 numbers
the resultant number is 5 7 9... | def addSameSize(h1, h2, carry):
def addList1(h1, h2, c):
if h1.next == None:
val = h2.data + h1.data + c
h1.data = val % 10
return val // 10
c = addList1(h1.next, h2.next, 0)
val = h1.data + h2.data + c
h1.data = val % 10
return val // 10
... | FUNC_DEF FUNC_DEF IF VAR NONE ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR RETURN VAR FU... |
Given two numbers represented by two linked lists, write a function that returns Sum list. The sum list is linked list representation of addition of two input numbers.
Example 1:
Input:
S1 = 3, S2 = 3
ValueS1 = {2,3,4}
ValueS2 = {3,4,5}
Output: 5 7 9
Explanation: After adding the 2 numbers
the resultant number is 5 7 9... | def reverse(h):
if h == None or h.next == None:
return h
curr = h
next = h.next
prev = None
while next:
curr.next = prev
prev = curr
curr = next
next = curr.next
curr.next = prev
return curr
def addSameSize(h1, h2, carry):
h1 = reverse(h1)
h2... | FUNC_DEF IF VAR NONE VAR NONE RETURN VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NONE WHILE VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VA... |
Given two numbers represented by two linked lists, write a function that returns Sum list. The sum list is linked list representation of addition of two input numbers.
Example 1:
Input:
S1 = 3, S2 = 3
ValueS1 = {2,3,4}
ValueS2 = {3,4,5}
Output: 5 7 9
Explanation: After adding the 2 numbers
the resultant number is 5 7 9... | def addSameSize(h1, h2, carry):
sm = h1.data + h2.data
res = None
if h1.next:
res = addSameSize(h1.next, h2.next, carry)
sm += carry.data
carry.data = sm // 10
x = Node(sm % 10)
x.next = res
return x
def addCarryToRemaining(head, curr, result, carry):
if head.next != curr:
... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NONE IF VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VA... |
Given two numbers represented by two linked lists, write a function that returns Sum list. The sum list is linked list representation of addition of two input numbers.
Example 1:
Input:
S1 = 3, S2 = 3
ValueS1 = {2,3,4}
ValueS2 = {3,4,5}
Output: 5 7 9
Explanation: After adding the 2 numbers
the resultant number is 5 7 9... | def addSameSize(h1, h2, carry):
if h2 is None and h1 is None:
return
new_node = Node(0)
if h2 is not None and h1 is not None:
new_node.next = addSameSize(h1.next, h2.next, carry)
elif h2 is None and h1 is not None:
new_node.next = addSameSize(h1.next, h2, carry)
result = (h1.... | FUNC_DEF IF VAR NONE VAR NONE RETURN ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR NONE VAR NONE ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR NONE VAR NONE ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER RETURN VAR FUNC_DE... |
Given two numbers represented by two linked lists, write a function that returns Sum list. The sum list is linked list representation of addition of two input numbers.
Example 1:
Input:
S1 = 3, S2 = 3
ValueS1 = {2,3,4}
ValueS2 = {3,4,5}
Output: 5 7 9
Explanation: After adding the 2 numbers
the resultant number is 5 7 9... | def reverse(head):
curr = head
prev = None
while curr:
next1 = curr.next
curr.next = prev
prev = curr
curr = next1
return prev
def addSameSize(h1, h2, carry):
if not h1 or not h2:
return
if not h1.next or not h2.next:
if h1.data + h2.data + carry... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NONE WHILE VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF IF VAR VAR RETURN IF VAR VAR IF BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VA... |
Given two numbers represented by two linked lists, write a function that returns Sum list. The sum list is linked list representation of addition of two input numbers.
Example 1:
Input:
S1 = 3, S2 = 3
ValueS1 = {2,3,4}
ValueS2 = {3,4,5}
Output: 5 7 9
Explanation: After adding the 2 numbers
the resultant number is 5 7 9... | def addSameSize(h1, h2, carry):
if h1.next == None and h2.next == None:
d = h1.data + h2.data
if d >= 10:
d -= 10
carry.data = 1
else:
carry.data = 0
return Node(d)
c = carry_data()
temp = addSameSize(h1.next, h2.next, c)
d = h1.data + ... | FUNC_DEF IF VAR NONE VAR NONE ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER RETURN FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CA... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | class Solution:
def isScramble(self, S1: str, S2: str):
d = {}
def solve(s1, s2):
if s1 == s2:
d[s1 + "#" + s2] = True
return True
if len(s1) == 1:
d[s1 + "#" + s2] = False
return False
if s1 + "#" ... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR DICT FUNC_DEF IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR STRING VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR STRING VAR NUMBER RETURN NUMBER IF BIN_OP BIN_OP VAR STRING VAR VAR RETURN VAR BIN_OP BIN_OP VAR STRING VAR FOR VAR FUNC_CALL VAR NUMBER FU... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | class Solution:
def __init__(self):
self.hmap = {}
def isScramble(self, S1: str, S2: str):
return self.helper(S1, S2)
def helper(self, s, t):
if (s, t) in self.hmap:
return self.hmap[s, t]
n = len(s)
if s == t:
self.hmap[s, t] = True
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FUNC_DEF VAR VAR RETURN FUNC_CALL VAR VAR VAR FUNC_DEF IF VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | class Solution:
def isScramble(self, S1: str, S2: str):
dic = dict()
def sol(S1, S2, i, j, n, m):
if j - i != m - n:
return 0
if j - i == 1 and S1[i] == S2[n]:
return 1
s = S1[i:j] + "_" + S2[n:m]
if s in dic:
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF BIN_OP VAR VAR BIN_OP VAR VAR RETURN NUMBER IF BIN_OP VAR VAR NUMBER VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR STRING VAR VAR VAR IF VAR VAR RETURN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR IF FUNC_CALL VAR VAR VAR VAR BI... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | class Solution:
def isScramble(self, S1: str, S2: str, d={}):
s1 = S1
s2 = S2
n1 = len(s1)
n2 = len(s2)
if n1 != n2:
return False
if n1 == 0:
return True
if s1 == s2:
return True
if n1 <= 1:
return False... | CLASS_DEF FUNC_DEF VAR VAR DICT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR VAR RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR RETURN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NU... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | class Solution:
def isScramble(self, s1: str, s2: str):
if len(s1) != len(s2):
return False
if s1 == s2:
return True
dp = {}
def solve(s1, s2):
n = len(s1)
if s1 == s2:
return True
if s1 + "" + s2 in dp:
... | CLASS_DEF FUNC_DEF VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER ASSIGN VAR DICT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN NUMBER IF BIN_OP BIN_OP VAR STRING VAR VAR RETURN VAR BIN_OP BIN_OP VAR STRING VAR ASSIGN VAR BIN_OP BIN_OP VAR STRING VAR NUMBER FOR VAR FUNC_... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | dic = {}
class Solution:
def isScramble(self, S1: str, S2: str):
if len(S1) == 0:
return True
if S1 == S2:
return True
if S1 + " " + S2 in dic:
return dic[S1 + " " + S2]
flag = False
for i in range(1, len(S1)):
if self.isScra... | ASSIGN VAR DICT CLASS_DEF FUNC_DEF VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF VAR VAR RETURN NUMBER IF BIN_OP BIN_OP VAR STRING VAR VAR RETURN VAR BIN_OP BIN_OP VAR STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | class Solution:
def isScramble(self, S1: str, S2: str):
mp = {}
def solve(a, b):
if a == b:
return True
if len(a) <= 1:
return False
key = a + " " + b
if mp.get(key) != None:
return mp[key]
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR DICT FUNC_DEF IF VAR VAR RETURN NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR STRING VAR IF FUNC_CALL VAR VAR NONE RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | class Solution:
def __init__(self):
self.scrambles = {}
def isScramble(self, s1: str, s2: str) -> bool:
if (s1, s2) in self.scrambles:
return self.scrambles[s1, s2]
if s1 == s2:
self.scrambles[s1, s2] = True
return True
ls = len(s1)
i... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FUNC_DEF VAR VAR IF VAR VAR VAR RETURN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR VAR VAR VAR ... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | class Solution:
def isScramble(self, S1: str, S2: str):
if S1 == "" or S2 == "":
return True
elif S1 == S2 or S1 == S2[::-1]:
return True
i = 1
while i < len(S1):
if self.match(S1[:i], S2[-i:]) and self.match(S1[i:], S2[:-i]):
if S... | CLASS_DEF FUNC_DEF VAR VAR IF VAR STRING VAR STRING RETURN NUMBER IF VAR VAR VAR VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR RETURN NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VA... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | class Solution:
def isScramble(self, S1, S2):
self.leftRight = [0, len(S1) - 1]
self.string1 = S1
self.string2 = S2
self.tuples = [(0, len(S1) - 1)]
self.failedCases = []
for i in range(2):
Return = self.switch(self.leftRight[i], i)
if Return:... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR RETURN NUMBER RETURN NUMBER FUNC_DEF NUMBER ASSIGN VAR VAR FUNC_CALL VAR... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | class Solution:
def __init__(self):
self.mp = {}
def isScramble(self, s1: str, s2: str):
if s1 == s2:
return True
if len(s1) != len(s2):
return False
if s1 + " " + s2 in self.mp:
return self.mp[s1 + " " + s2]
n = len(s1)
for i... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FUNC_DEF VAR VAR IF VAR VAR RETURN NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN NUMBER IF BIN_OP BIN_OP VAR STRING VAR VAR RETURN VAR BIN_OP BIN_OP VAR STRING VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR V... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | class Solution:
def __init__(self):
self.map = {}
def isScramble(self, s1, s2):
if (s1, s2) in self.map:
return self.map[s1, s2]
if len(s1) != len(s2):
self.map[s1, s2] = False
return False
if s1 == s2:
self.map[s1, s2] = True
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT FUNC_DEF IF VAR VAR VAR RETURN VAR VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN NUMBER IF VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | class Solution:
def isScramble(self, S1: str, S2: str):
s1, s2 = S1, S2
if len(s1) != len(s2) or sorted(s1) != sorted(s2):
return False
if s1 == s2:
return True
n = len(s1)
dp = [[([-1] * n) for _ in range(n)] for _ in range(n + 1)]
for i in r... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR VAR VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR F... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | import sys
sys.setrecursionlimit(100000)
class Solution:
def __init__(self):
self.dp = dict()
def isScramble(self, S1: str, S2: str):
if len(S1) != len(S2):
return False
if S1 == S2:
return True
if S1 + S2 in self.dp:
return self.dp[S1 + S... | IMPORT EXPR FUNC_CALL VAR NUMBER CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_DEF VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER IF BIN_OP VAR VAR VAR RETURN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF FUNC_CALL VAR VAR NUMBER VAR VAR NU... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | class Solution:
def isScramble(self, S1: str, S2: str):
def helper(s1, s2, memo):
if (s1, s2) in memo:
return memo[s1, s2]
if sorted(s1) != sorted(s2):
memo[s1, s2] = False
return False
if s1 == s2:
memo[s1... | CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF IF VAR VAR VAR RETURN VAR VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN NUMBER IF VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR FU... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | class Solution:
def isScramble(self, s1: str, s2: str):
hsh = {}
return self.check(s1, s2, hsh)
def check(self, s1, s2, hsh):
n = len(s1)
if s1 == s2:
hsh[s1 + s1] = True
return True
if s1 + s2 in hsh:
return hsh[s1 + s2]
for ... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR DICT RETURN FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER RETURN NUMBER IF BIN_OP VAR VAR VAR RETURN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR... |
Given two strings S1 and S2 of equal length, the task is to determine if S2 is a scrambled form of S1.
Scrambled string: Given string str, we can represent it as a binary tree by partitioning it into two non-empty substrings recursively.
Below is one possible representation of str = coder:
To scramble the string, we ... | class Solution:
def isScramble(self, S1: str, S2: str):
if len(S1) != len(S2):
return False
self.mappa = dict()
self.s1 = S1
self.s2 = S2
self.n = len(S1)
return self.func(0, 0, self.n)
def func(self, ind1, ind2, size):
fetch = self.mappa.get... | CLASS_DEF FUNC_DEF VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR NUMBER NUMBER VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR NONE RETURN VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR V... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | n = int(input())
l = list(map(int, input().split()))
if n >= 130:
print("Yes")
else:
d = {}
for i in range(n):
if l[i] in d:
d[l[i]].append(i)
else:
d[l[i]] = [i]
f = False
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, ... | 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 DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR LIST VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_C... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | def xorexists(n, A):
if n >= 130:
return True
else:
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
temp = A[i] ^ A[j] ^ A[k]
if temp in A[k + 1 :]:
return True
return False... | FUNC_DEF IF VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF VAR VAR BIN_OP VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | n = int(input())
L = list(map(int, input().split()))
d = {}
a = 0
b = 0
for i in L:
try:
d[i] += 1
if d[i] == 2:
a += 1
elif d[i] == 4:
a -= 1
b += 1
break
except:
d[i] = 1
if a >= 2 or b >= 1:
print("Yes")
else:
d = {}
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER IF VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR ... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | def nest(n):
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
for a in range(k + 1, n):
if l[i] ^ l[j] ^ l[k] ^ l[a] == 0:
return True
return False
n = int(input())
l = list(map(int, input().split()))
if n > ... | FUNC_DEF FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VA... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | from sys import stdin
def solve():
n = int(input())
d = {}
a = list(map(int, input().split()))
if n < 4:
return "No"
elif n >= 130:
return "Yes"
else:
for i in range(0, n):
for j in range(i + 1, n):
for k in range(j + 1, n):
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER RETURN STRING IF VAR NUMBER RETURN STRING FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | n = int(input())
arr = list(map(int, input().split()))
def xor():
if n > 67:
print("Yes")
else:
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
for l in range(k + 1, n):
if arr[i] ^ arr[j] ^ arr[k] ^... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | def fun(l, n):
if n >= 138:
return "Yes"
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
for l1 in range(k + 1, n):
c = l[i] ^ l[j] ^ l[k] ^ l[l1]
if c == 0:
return "Yes"
return... | FUNC_DEF IF VAR NUMBER RETURN STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR IF VAR NUMBER RETURN STRING RETURN STRING ASSIGN VAR FUNC_CAL... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | try:
n = int(input())
l = list(map(int, input().split()))
cont = 1
if n >= 130:
print("Yes")
cont = 0
if cont:
flag = 0
for x in range(n):
for y in range(x + 1, n):
for z in range(y + 1, n):
for a in range(z + 1, n):
... | 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 IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | n = int(input())
a = list(map(int, input().split()))
if n >= 130:
print("Yes")
else:
ans = 0
for i in range(n - 3):
for j in range(i + 1, n - 2):
for k in range(j + 1, n - 1):
for l in range(k + 1, n):
if a[i] ^ a[j] ^ a[k] ^ a[l] == 0:
... | 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 FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | n = int(input())
arr = list(map(int, input().split()))
if n >= 130:
print("Yes")
else:
_map = {}
for i in range(len(arr)):
for j in range(i + 1, len(arr)):
a = arr[i] ^ arr[j]
if a in _map:
if _map[a][1] < i:
print("Yes")
... | 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 DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF VAR VAR IF VAR VAR NUMB... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | try:
def gray(n, arr):
if n < 4:
return False
elif n > 130:
return True
else:
for i in range(0, n):
for j in range(i + 1, n):
for k in range(j + 1, n):
for w in range(k + 1, n):
... | FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | def greysim(n, A):
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
for l in range(k + 1, n):
if A[i] ^ A[j] ^ A[k] ^ A[l] == 0:
print("Yes")
return
print("No")
return
n = int(inpu... | FUNC_DEF FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR FUNC_CALL VAR... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | n = int(input())
A = [int(i) for i in input().strip().split()]
s = set()
if n >= 130:
print("Yes")
else:
check = False
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
if A[i] ^ A[j] ^ A[k] in s:
check = True
b... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP ... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | a = int(input())
table = {}
bb = list(map(int, input().split()))
for i in range(len(bb)):
table[bb[i]] = i
t = 0
if a >= 130:
print("Yes")
else:
for i in range(a):
for j in range(i + 1, a):
for k in range(j + 1, a):
c = bb[i] ^ bb[j] ^ bb[k]
if c in table ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | def compute(a):
n = len(a)
res = "No"
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
for l in range(k + 1, n):
if a[i] ^ a[j] ^ a[k] ^ a[l] == 0:
res = "Yes"
return res
return ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR STRING RETURN VAR RETURN VAR ASS... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | n = int(input())
a = list(map(int, input().split()))
if n >= 130:
print("Yes")
else:
flag = 0
i = 0
while i < n:
j = i + 1
while j < n:
k = j + 1
while k < n:
l = k + 1
while l < n:
if a[i] ^ a[j] ^ a[k] ^ a[l] =... | 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 ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | n = int(input())
arr = list(map(int, input().split()))
limit = 64 * 2 + 10
if n >= limit:
print("Yes")
else:
flag = 0
for i in range(len(arr)):
for j in range(i + 1, len(arr)):
for k in range(j + 1, len(arr)):
for l in range(k + 1, len(arr)):
if arr[i]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CA... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | def binary_search(a, x):
left = 0
right = len(a) - 1
while left <= right:
mid = (left + right) // 2
if a[mid] == x:
return True
elif a[mid] > x:
right = mid - 1
else:
left = mid + 1
return False
def search(a, x, i, j, k):
n = len(... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR V... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | T = int(input())
if T >= 130:
print("Yes")
exit()
num = []
num = list(map(int, input().split()))
for i in range(T):
for j in range(i + 1, T):
for k in range(j + 1, T):
for l in range(k + 1, T):
if num[i] ^ num[j] ^ num[k] ^ num[l] == 0:
print("Yes")
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | def check(arr):
for i in range(0, len(arr) - 3):
for j in range(i + 1, len(arr) - 2):
for k in range(j + 1, len(arr) - 1):
for x in range(k + 1, len(arr)):
if arr[i] ^ arr[j] ^ arr[k] ^ arr[x] == 0:
return "Yes"
return "No"
try:
... | FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ... |
The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0≤A[i]<2^{64}), such that every tw... | n = int(input())
m = [*map(int, input().split())]
if n > 130:
print("Yes")
exit(0)
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
t = m[i] ^ m[j] ^ m[k]
if t in m[k + 1 :]:
print("Yes")
exit(0)
print("No") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VA... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
ans = []
arr = []
digmap = dict()
digmap[2] = ["a", "b", "c"]
digmap[3] = ["d", "e", "f"]
digmap[4] = ["g", "h", "i"]
digmap[5] = ["j", "k", "l"]
digmap[6] = ["m", "n", "o"]
digmap[7] = ["p", "q",... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER LIST STRING STRING STRING ASSIGN VAR NUMBER LIST STRING STRING STRING ASSIGN VAR NUMBER LIST STRING STRING STRING ASSIGN VAR NUMBER LIST STRING STRING STRING ASSIGN VAR NUMBER LIST STRING STRING STRING ASSIGN VAR NUMBER LIST S... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def check(self, a, i, out, n, dic, ans):
if i >= n:
ans.append("".join(out))
return
for j in range(len(dic[a[i]])):
out.append(dic[a[i]][j])
self.check(a, i + 1, out, n, dic, ans)
out.pop()
def possibleWords(self, a, N... | CLASS_DEF FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR RETURN FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUM... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
ans = ""
res = []
dirc = {
(1): [],
(2): ["a", "b", "c"],
(3): ["d", "e", "f"],
(4): ["g", "h", "i"],
(5): ["j", "k", "l"],
(6): ["m", "n", "o"],
(7): ["p", "q"... | CLASS_DEF FUNC_DEF ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING STRING LIST STRING STRING S... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
res = {
(2): ["a", "b", "c"],
(3): ["d", "e", "f"],
(4): ["g", "h", "i"],
(5): ["j", "k", "l"],
(6): ["m", "n", "o"],
(7): ["p", "q", "r", "s"],
(8): ["t", "u", "v"],
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING STRING FUNC_DE... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
keys = {
(2): ("a", "b", "c"),
(3): ("d", "e", "f"),
(4): ("g", "h", "i"),
(5): ("j", "k", "l"),
(6): ("m", "n", "o"),
(7): ("p", "q", "r", "s"),
(8): ("t", "u", "v"),
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR LIST FUNC_DEF IF FUNC_CALL VAR VAR V... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def util(self, a, d, i, n, ans):
global fans
if i == n:
fans.append(ans)
return
for j in d[a[i]]:
self.util(a, d, i + 1, n, ans + j)
def possibleWords(self, a, N):
global fans
fans = []
d = {
(2): "... | CLASS_DEF FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING EXPR FUNC_CALL VAR VAR ... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def helper(self, index, a, N, curr, d, res):
if index == N:
res.append(curr)
return
val = a[index]
word = d[val]
for letter in word:
curr += letter
self.helper(index + 1, a, N, curr, d, res)
curr = curr[:-1]... | CLASS_DEF FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STR... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | from itertools import product
class Solution:
def possibleWords(self, a, N):
dict = {
"2": "abc",
"3": "def",
"4": "ghi",
"5": "jkl",
"6": "mno",
"7": "pqrs",
"8": "tuv",
"9": "wxyz",
}
if not ... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING IF VAR RETURN LIST ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR EX... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | def solve(a, output, index, ans, mapping):
if index >= len(a):
ans.append(output)
return
number = a[index]
value = mapping[number]
for i in range(len(value)):
output += value[i]
solve(a, output, index + 1, ans, mapping)
output = output[: len(output) - 1]
class S... | FUNC_DEF IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR NU... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, n):
b = []
ans = []
ind_max = []
ind = [(0) for i in range(n)]
fac = [(1) for i in range(n)]
for i in range(n):
if a[i] == 2:
s = "abc"
elif a[i] == 3:
s = "def"
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR STRING IF VAR VAR NUMBER ASSIGN VAR STRING IF VAR VAR NUMBER ASSIGN VAR STRING IF VAR VAR NUMBER ASSIGN VAR STRING IF ... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
wordmap = {
(2): "abc",
(3): "def",
(4): "ghi",
(5): "jkl",
(6): "mno",
(7): "pqrs",
(8): "tuv",
(9): "wxyz",
}
def possibleWords(self, a, N):
res = []
self.possibleWordsHelper(a, N, 0, "", res)
res.sort... | CLASS_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING FUNC_DEF ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR VAR NUMBER STRING VAR EXPR FUNC_CALL VAR RETURN VAR FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR FUNC_CALL VAR FUNC_CA... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, arr, N):
hm = {
(1): "",
(2): "abc",
(3): "def",
(4): "ghi",
(5): "jkl",
(6): "mno",
(7): "pqrs",
(8): "tuv",
(9): "wxyz",
(10): "*",
(... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR LIST FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR RETURN ASSIGN VAR VAR VAR FOR V... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
digit = {
(2): "abc",
(3): "def",
(4): "ghi",
(5): "jkl",
(6): "mno",
(7): "pqrs",
(8): "tuv",
(9): "wxyz",
}
def f(ind, path):
if ind ... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN FOR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL V... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
codes = ["", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"]
if len(a) == 0:
res = []
res.append("")
return res
ch = a[0]
ros = a[1:]
rres = self.possibleWords(ros, N)
co... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR STRING RETURN VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR FOR VAR VA... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, arr, N):
d = {
(2): "abc",
(3): "def",
(4): "ghi",
(5): "jkl",
(6): "mno",
(7): "pqrs",
(8): "tuv",
(9): "wxyz",
}
o = []
def recurr(d, i, out, ar... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR LIST FUNC_DEF IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR RETURN FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR NUMBER VAR VAR NU... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
d = {
(2): "abc",
(3): "def",
(4): "ghi",
(5): "jkl",
(6): "mno",
(7): "pqrs",
(8): "tuv",
(9): "wxyz",
}
ans = [""]
for r in range(N):
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR LIST STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR RETURN FUNC_CALL VAR VAR |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
arr = ["", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"]
output = ""
ans = []
ind = 0
def find(ind, cur, output, ans, a, arr):
if cur == N:
ans.append(output)
return
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CA... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def __init__(self):
self.mapping = {
(2): ["a", "b", "c"],
(3): ["d", "e", "f"],
(4): ["g", "h", "i"],
(5): ["j", "k", "l"],
(6): ["m", "n", "o"],
(7): ["p", "q", "r", "s"],
(8): ["t", "u", "v"],
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING STRING ASSIGN ... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, n):
def solve(index, temp, ans, s, n):
if index == n:
ans.append(s)
return
for j in temp[index]:
s += j
solve(index + 1, temp, ans, s, n)
s = s[:-1]
d... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN FOR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR LIST ASSIGN V... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def Phone_number(self, arr, n, i, str1, res, op):
if i == n:
res.append(op)
return
no = str1[arr[i]]
for op1 in no:
op1 = op + op1
self.Phone_number(arr, n, i + 1, str1, res, op1)
op1 = "".join([op1[i] for i in rang... | CLASS_DEF FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR VAR VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST STRING STRING S... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
m = {
"2": "abc",
"3": "def",
"4": "ghi",
"5": "jkl",
"6": "mno",
"7": "pqrs",
"8": "tuv",
"9": "wxyz",
}
phnum = ""
for i in a:
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR ... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
all = {
(2): ["a", "b", "c"],
(3): ["d", "e", "f"],
(4): ["g", "h", "i"],
(5): ["j", "k", "l"],
(6): ["m", "n", "o"],
(7): ["p", "q", "r", "s"],
(8): ["t", "u", "v"],
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING STRING ASSIGN ... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def hell(self, a, i, N, cur, dic, res):
if len(cur) == len(a):
res.append(cur)
return
x = dic.get(a[i])
for j in x:
cur = cur + j
Solution.hell(self, a, i + 1, N, cur, dic, res)
cur = cur[: len(cur) - 1]
ret... | CLASS_DEF FUNC_DEF IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR STRING ASSIGN VAR LIST... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
letters = [
["a", "b", "c"],
["d", "e", "f"],
["g", "h", "i"],
["j", "k", "l"],
["m", "n", "o"],
["p", "q", "r", "s"],
["t", "u", "v"],
["w", "x", "y", "z"],
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING STRING ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR STRING EXPR FUNC_C... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
ans = []
dic = {
(2): "abc",
(3): "def",
(4): "ghi",
(5): "jkl",
(6): "mno",
(7): "pqrs",
(8): "tuv",
(9): "wxyz",
}
def helper(i, a, N):
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING FUNC_DEF IF VAR VAR RETURN LIST STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR ... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | keypad = ["", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"]
class Solution:
def possibleWords(self, a, N):
def helper(i, w, res, a, N):
if i == N:
res.append(w)
return
for j in range(len(keypad[a[i]])):
helper(i + 1,... | ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING CLASS_DEF FUNC_DEF FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
keypad = {
(2): "abc",
(3): "def",
(4): "ghi",
(5): "jkl",
(6): "mno",
(7): "pqrs",
(8): "tuv",
(9): "wxyz",
}
def generate_list(list_to_be_generat... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING FUNC_DEF IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
keymap = ["", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"]
output = []
def recursive(curr=0, word=""):
if curr == N:
return output.append(word)
for i in range(len(keymap[a[curr]])):
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR LIST FUNC_DEF NUMBER STRING IF VAR VAR RETURN FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VA... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
res = []
self.func(a, N, 0, res, "")
return res
def func(self, a, N, index, res, s):
if index == N:
if len(s) > 0:
res.append(s)
return res
temp = a[index]
if temp == 0 or tem... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR VAR NUMBER VAR STRING RETURN VAR FUNC_DEF IF VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR LIST LIST LIST LIST STRING S... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
res = []
digg = {
(2): "abc",
(3): "def",
(4): "ghi",
(5): "jkl",
(6): "mno",
(7): "pqrs",
(8): "tuv",
(9): "wxyz",
}
def back(i, curr):
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING FUNC_DEF IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR IF VAR ... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
c = ""
for i in a:
c += str(i)
def helper(i, m):
if i > N:
return
if i == N:
new = ""
for j in subset:
new += j
ans.append(... | CLASS_DEF FUNC_DEF ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR VAR RETURN IF VAR VAR ASSIGN VAR STRING FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CA... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
ans = []
def create(idx, temp):
if idx == N:
ans.append(temp)
return
for c in m[a[idx]]:
create(idx + 1, temp + c)
m = {
(2): "abc",
(3): "def",
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING EXPR FUNC_CALL VAR NUMBER STRING RE... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
hash = [".", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"]
def comb(index, n, str, out, ll):
if index == n:
ll.append(out)
return ll
tt = hash[str[index] - 1]
for i in ran... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BI... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | import itertools as it
class Solution:
def possibleWords(self, a, N):
m = {
(2): ["a", "b", "c"],
(3): ["d", "e", "f"],
(4): ["g", "h", "i"],
(5): ["j", "k", "l"],
(6): ["m", "n", "o"],
(7): ["p", "q", "r", "s"],
(8): ["t... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING STRING ... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
arr = [
[],
[],
["a", "b", "c"],
["d", "e", "f"],
["g", "h", "i"],
["j", "k", "l"],
["m", "n", "o"],
["p", "q", "r", "s"],
["t", "u", "v"],
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST LIST LIST LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING STRING ASSIGN VAR STRING ASSIGN VAR LIST EXPR FUNC_CALL VAR ... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | def solve(a, output, ans, d, index, N):
if index == N:
s = "".join(output[:])
ans.append(s)
return ans
num = a[index]
value = d[num]
for i in range(len(value)):
output.append(value[i])
solve(a, output, ans, d, index + 1, N)
output.pop(-1)
class Solution:... | FUNC_DEF IF VAR VAR ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR ... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def __init__(self):
self.phone_dict = dict()
self.phone_dict[2] = "abc"
self.phone_dict[3] = "def"
self.phone_dict[4] = "ghi"
self.phone_dict[5] = "jkl"
self.phone_dict[6] = "mno"
self.phone_dict[7] = "pqrs"
self.phone_dict[8] = "tuv"
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER STRING ASSIGN VAR NUMBER STRING ASSIGN VAR LIST FUNC_DEF NUMBER STRING IF VAR VAR EXPR FUNC_CALL VAR VAR RET... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
def helper(cur, ind, a, N, res, mapp):
if ind == N:
res.append(cur)
return res
for i in mapp[a[ind]]:
helper(cur + i, ind + 1, a, N, res, mapp)
mapp = {
(2): ["a", "b... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRI... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def helper(self, N, curr, i, l):
if N == i:
l.append(curr)
return
if len(keys[i]) == 3:
self.helper(N, curr + keys[i][0], i + 1, l)
self.helper(N, curr + keys[i][1], i + 1, l)
self.helper(N, curr + keys[i][2], i + 1, l)
... | CLASS_DEF FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN IF FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL ... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | numbs = {
"2": "abc",
"3": "def",
"4": "ghi",
"5": "jkl",
"6": "mno",
"7": "pqrs",
"8": "tuv",
"9": "wxyz",
}
class Solution:
def possibleWords(self, a, N):
num = ""
for i in a:
num += str(i)
ans = self.combo(num)
return ans
def com... | ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING CLASS_DEF FUNC_DEF ASSIGN VAR STRING FOR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR VAR VAR NUMBER ASSIGN V... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
phone_dict = {
(2): "abc",
(3): "def",
(4): "ghi",
(5): "jkl",
(6): "mno",
(7): "pqrs",
(8): "tuv",
(9): "wxyz",
}
arr = [phone_dict[i] for i in a]
... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR VAR VAR VAR VAR FUNC_DEF IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBE... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
keypad = {
(1): [],
(2): ["a", "b", "c"],
(3): ["d", "e", "f"],
(4): ["g", "h", "i"],
(5): ["j", "k", "l"],
(6): ["m", "n", "o"],
(7): ["p", "q", "r", "s"],
(8): ["... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING ST... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, arr, N):
dictt = {
(2): "abc",
(3): "def",
(4): "ghi",
(5): "jkl",
(6): "mno",
(7): "pqrs",
(8): "tuv",
(9): "wxyz",
}
res = []
self.dfs(dictt, arr... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR VAR STRING VAR RETURN VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN FOR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
characters = "abcdefghijklmnopqrstuvwxyz"
st = 0
numToLetters = {}
for i in range(2, 10):
if i == 7 or i == 9:
ed = st + 4
else:
ed = st + 3
numToLetters[i] = [st, ed]
... | CLASS_DEF FUNC_DEF ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR LIST VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUN... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def helper(self, input_arr, n, temp, idx, result, button_arr):
if idx == n:
result.append(temp)
return
j = 0
while j < len(button_arr[input_arr[idx]]):
self.helper(
input_arr,
n,
temp + butto... | CLASS_DEF FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING EXPR... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
d = {
(1): "",
(2): "abc",
(3): "def",
(4): "ghi",
(5): "jkl",
(6): "mno",
(7): "pqrs",
(8): "tuv",
(9): "wxyz",
}
ans = []
w = ... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR LIST ASSIGN VAR STRING FOR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN ASSIGN VA... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def __init__(self):
self.list_numbers = [
"",
"abc",
"def",
"ghi",
"jkl",
"mno",
"pqrs",
"tuv",
"wxyz",
]
self.char_list = []
def prepare_words_phone_digits(self,... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR LIST FUNC_DEF IF FUNC_CALL VAR VAR NUMBER FOR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR NUMBER FOR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR FUNC_DEF ASSIGN VAR LIST... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
possible_nums = {
(2): "abc",
(3): "def",
(4): "ghi",
(5): "jkl",
(6): "mno",
(7): "pqrs",
(8): "tuv",
(9): "wxyz",
}
def possibleWords(self, a, N, i=0, permute=""):
if N > len(a):
N = len(a)
if i ==... | CLASS_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING FUNC_DEF NUMBER STRING IF VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR LIST FOR... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
def numb(s1, s2):
x = []
for i in d[s1]:
for j in d[s2]:
y = i + j
x.append(y)
d[s1 + s2] = x
return s1 + s2
d = {
"2": ["a", "b", "c"... | CLASS_DEF FUNC_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING ... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def possibleWords(self, a, N):
def calc(ind, s):
if ind == N:
ans.append(s)
return
for i in dic[a[ind]]:
s += i
calc(ind + 1, s)
s = s[:-1]
ans = []
dic = ["", "", "abc"... | CLASS_DEF FUNC_DEF FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN FOR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING EXPR FUNC_CALL VAR NUMBER STRING RETURN VAR |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
_dict = {
(1): (),
(2): ("a", "b", "c"),
(3): ("d", "e", "f"),
(4): ("g", "h", "i"),
(5): ("j", "k", "l"),
(6): ("m", "n", "o"),
(7): ("p", "q", "r", "s"),
(8): ("t", "u", "v"),
(9): ("w", "x", "y", "z"),
}
def possible... | CLASS_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING FUNC_DEF ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR V... |
Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.
Example 1:
Input: N = 3, a[] = {2, 3, 4}
Output:
adg adh adi aeg aeh aei afg afh afi
bdg bdh bdi beg beh bei bfg bfh bfi
cdg cdh cdi ceg ceh cei... | class Solution:
def __init__(self):
self.phone = {
(1): [],
(2): ["a", "b", "c"],
(3): ["d", "e", "f"],
(4): ["g", "h", "i"],
(5): ["j", "k", "l"],
(6): ["m", "n", "o"],
(7): ["p", "q", "r", "s"],
(8): ["t", "u"... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER LIST LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING STRING STRING LIST STRING STRING STRING LIST STRING STRING ST... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.