description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Given two sorted linked lists consisting of N and M nodes respectively. The task is to merge both of the list (in-place) and return head of the merged list. Example 1: Input: N = 4, M = 3 valueN[] = {5,10,15,40} valueM[] = {2,3,20} Output: 2 3 5 10 15 20 40 Explanation: After merging the two linked lists, we have me...
def sortedMerge(head1, head2): finalnode = Node(0) dongu = True if head1.data < head2.data: finalnode = head1 head1 = head1.next else: finalnode = head2 head2 = head2.next firsthead = finalnode while head1 != None and head2 != None: if head1.data < head2.d...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR NONE VAR NONE IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NONE ASSIGN VAR VAR IF VAR NONE ASSIGN VAR ...
Given two sorted linked lists consisting of N and M nodes respectively. The task is to merge both of the list (in-place) and return head of the merged list. Example 1: Input: N = 4, M = 3 valueN[] = {5,10,15,40} valueM[] = {2,3,20} Output: 2 3 5 10 15 20 40 Explanation: After merging the two linked lists, we have me...
def sortedMerge(head1, head2): L1 = [] n = head1 while n is not None: L1.append(n.data) n = n.next L2 = [] n = head2 while n is not None: L2.append(n.data) n = n.next L = L1 + L2 L.sort() head1.next = None n = head1 while L: a = L.pop(0...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR NONE EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR NONE EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NONE ASSIGN VAR VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_...
Given two sorted linked lists consisting of N and M nodes respectively. The task is to merge both of the list (in-place) and return head of the merged list. Example 1: Input: N = 4, M = 3 valueN[] = {5,10,15,40} valueM[] = {2,3,20} Output: 2 3 5 10 15 20 40 Explanation: After merging the two linked lists, we have me...
def sortedMerge(head1, head2): temp1 = head1 temp2 = head2 result = [] while temp1.next is not None: result.append(temp1.data) temp1 = temp1.next result.append(temp1.data) temp1.next = head2 while temp2 is not None: result.append(temp2.data) temp2 = temp2.next...
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NONE EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE VAR NONE EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NONE ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR RETURN VA...
Given an array of positive integers and many queries for divisibility. In every query Q[i], we are given an integer K , we need to count all elements in the array which are perfectly divisible by K. Example 1: Input: N = 6 A[] = { 2, 4, 9, 15, 21, 20} M = 3 Q[] = { 2, 3, 5} Output: 3 3 2 Explanation: Multiples of '2...
def getMaxandMinProduct(arr, Q, n, M): MAX = max(arr) global ans ans = [0] * (MAX + 1) cnt = [0] * (MAX + 1) for i in range(n): cnt[arr[i]] += 1 for i in range(1, MAX + 1): for j in range(i, MAX + 1, i): ans[i] += cnt[j] ans2 = [] for i in Q: if i > le...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR IF...
Given an array of positive integers and many queries for divisibility. In every query Q[i], we are given an integer K , we need to count all elements in the array which are perfectly divisible by K. Example 1: Input: N = 6 A[] = { 2, 4, 9, 15, 21, 20} M = 3 Q[] = { 2, 3, 5} Output: 3 3 2 Explanation: Multiples of '2...
def getMaxandMinProduct(A, Q, N, M): ans = [0] * M mx = max(A) count = [0] * (mx + 1) tmp_ans = [0] * (mx + 1) for i in range(N): count[A[i]] = count[A[i]] + 1 mxq = max(Q) for j in range(1, mxq + 1): for k in range(j, mx + 1, j): tmp_ans[j] = count[k] + tmp_ans[j...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR V...
Given an array of positive integers and many queries for divisibility. In every query Q[i], we are given an integer K , we need to count all elements in the array which are perfectly divisible by K. Example 1: Input: N = 6 A[] = { 2, 4, 9, 15, 21, 20} M = 3 Q[] = { 2, 3, 5} Output: 3 3 2 Explanation: Multiples of '2...
def getMaxandMinProduct(A, Q, N, M): m = max(max(A), max(Q)) l = [0] * (m + 1) k = [] c = [0] * (m + 1) for j in A: l[j] += 1 for i in range(1, m + 1): for j in range(i, m + 1, i): if l[j] != 0: c[i] += l[j] for i in Q: k.append(c[i]) r...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR IF VAR VAR NUMBE...
Given an array of positive integers and many queries for divisibility. In every query Q[i], we are given an integer K , we need to count all elements in the array which are perfectly divisible by K. Example 1: Input: N = 6 A[] = { 2, 4, 9, 15, 21, 20} M = 3 Q[] = { 2, 3, 5} Output: 3 3 2 Explanation: Multiples of '2...
def getMaxandMinProduct(A, Q, N, M): m = max(A) ans = [0] * (m + 1) cnt = [0] * (m + 1) for i in range(N): cnt[A[i]] += 1 for i in range(1, m + 1): for j in range(i, m + 1, i): ans[i] += cnt[j] res = [] for i in Q: if i > m: res.append(0) ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR IF...
Given an array of positive integers and many queries for divisibility. In every query Q[i], we are given an integer K , we need to count all elements in the array which are perfectly divisible by K. Example 1: Input: N = 6 A[] = { 2, 4, 9, 15, 21, 20} M = 3 Q[] = { 2, 3, 5} Output: 3 3 2 Explanation: Multiples of '2...
def getMaxandMinProduct(A, Q, N, M): n = max(A) sieve = [0] * (n + 1) for x in A: sieve[x] += 1 res = [] for x in Q: if x == 0: res.append(0) continue cnt = 0 mul = 1 while mul * x <= n: cnt += sieve[mul * x] mul...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR
Given an array of positive integers and many queries for divisibility. In every query Q[i], we are given an integer K , we need to count all elements in the array which are perfectly divisible by K. Example 1: Input: N = 6 A[] = { 2, 4, 9, 15, 21, 20} M = 3 Q[] = { 2, 3, 5} Output: 3 3 2 Explanation: Multiples of '2...
def getMaxandMinProduct(A, Q, N, M): answer = [] ans = helper(A, N) max1 = max(A) for i in range(M): if Q[i] > max1: answer.append(0) else: answer.append(ans[Q[i]]) return answer def helper(arr, n): MAX = max(arr) ans = [] ans = [0] * (MAX + 1) ...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST...
Given an array of positive integers and many queries for divisibility. In every query Q[i], we are given an integer K , we need to count all elements in the array which are perfectly divisible by K. Example 1: Input: N = 6 A[] = { 2, 4, 9, 15, 21, 20} M = 3 Q[] = { 2, 3, 5} Output: 3 3 2 Explanation: Multiples of '2...
def getMaxandMinProduct(A, Q, N, M): maxi = max(A + Q) B = [0] * (maxi + 1) for i in A: B[i] += 1 for i in range(1, maxi + 1): for j in range(i + i, maxi + 1, i): B[i] += B[j] L = [] for i in Q: L.append(B[i]) return L
FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.l = [homepage] self.curr = 0 def visit(self, url: str) -> None: if self.curr == len(self.l) - 1: self.l.append(url) self.curr += 1 else: while self.curr < len(self.l) - 1: ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER FUNC_DEF VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR NUMBER NONE FUNC_DEF VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER RETURN VAR NUMBER...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.history = [] self.future = [] self.history.append(homepage) def visit(self, url: str) -> None: self.history.append(url) self.future = [] def back(self, steps: int) -> str: while steps > 0 and len...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR FUNC_DEF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST NONE FUNC_DEF VAR WHILE VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER RETURN VAR NUMBER VAR FUNC_DEF VAR WHILE VAR NUMBER FUNC_CALL VAR VAR ...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.curIndex = 0 self.history = [homepage] def visit(self, url: str) -> None: self.history = self.history[: self.curIndex + 1] self.history.append(url) self.curIndex += 1 def back(self, steps: int) -> str: ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR LIST VAR FUNC_DEF VAR ASSIGN VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER NONE FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR RETURN VAR VAR VAR FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR RETURN VAR...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.arr = [homepage] self.cur = 0 self.f = 0 def visit(self, url: str) -> None: self.arr = self.arr[: self.cur + 1] self.arr.append(url) self.cur += 1 self.f = 0 def back(self, steps: int) ->...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF VAR ASSIGN VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER NONE FUNC_DEF VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR RETURN VAR VAR VAR FUNC_DEF VAR IF VA...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.history = [homepage] self.forward_pages = [] def visit(self, url): self.history.append(url) self.forward_pages = [] def back(self, steps): while steps > 0 and len(self.history) > 1: self.forw...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST VAR ASSIGN VAR LIST FUNC_DEF EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FUNC_DEF WHILE VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER RETURN VAR NUMBER FUNC_DEF WHILE VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER RETURN VAR NUMBER
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.hashM = {} self.maxIndex, self.currIndex = 0, 0 self.hashM[self.currIndex] = homepage def visit(self, url: str) -> None: self.hashM[self.currIndex + 1] = url self.currIndex = self.currIndex + 1 self.m...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR DICT ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_DEF VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR NONE FUNC_DEF VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN VAR VAR VAR FUNC_DEF VAR IF BIN_OP VAR...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.fwd = [] self.bck = [homepage] self.lastback = homepage def visit(self, url: str) -> None: self.bck.append(url) self.lastback = url self.fwd = [] def back(self, steps: int) -> str: el = N...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST ASSIGN VAR LIST VAR ASSIGN VAR VAR FUNC_DEF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST NONE FUNC_DEF VAR ASSIGN VAR NONE WHILE VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER RETURN VAR NUMBER VAR FUNC_DEF VAR ASSIGN VAR NONE WHILE VAR VAR E...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.prev = [homepage] self.future = [] def visit(self, url: str) -> None: self.prev.append(url) self.future = [] def back(self, steps: int) -> str: size = len(self.prev) - 1 for _ in range(min(steps,...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST VAR ASSIGN VAR LIST FUNC_DEF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST NONE FUNC_DEF VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR RETURN VAR NUMBER VAR FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.l = [homepage] self.cur = 0 self.max = 0 def visit(self, url: str) -> None: self.cur += 1 if self.cur == len(self.l): self.l.append(url) else: self.l[self.cur] = url se...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR NONE FUNC_DEF VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER RETURN VAR VAR VAR FUNC_DEF VAR VAR VAR IF VAR VAR ASSIGN VAR VAR RETURN VAR ...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.history = [homepage] self.idx = 0 def visit(self, url: str) -> None: for _ in range(len(self.history) - 1 - self.idx): self.history.pop() self.history.append(url) self.idx += 1 def back(self,...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER FUNC_DEF VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR NUMBER NONE FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR RETURN VAR VAR VAR FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR BIN_OP...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class Node: def __init__(self, url: str): self.url = url self.next = None self.prev = None class BrowserHistory: def __init__(self, homepage: str): self.head = Node(homepage) self.current_node = self.head def visit(self, url: str) -> None: new_node = Node...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR VAR ASSIGN VAR NONE ASSIGN VAR NONE CLASS_DEF FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR NONE FUNC_DEF VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR RETURN VAR VAR FUNC_DEF VA...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: curr = None backHistory = 0 forwardHistory = 0 def __init__(self, homepage: str): self.curr = Node(homepage) def visit(self, url: str) -> None: self.forwardHistory = 0 self.curr.next = Node(url) self.curr.next.prev = self.curr self.back...
CLASS_DEF ASSIGN VAR NONE ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR NONE FUNC_DEF VAR WHILE VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR VAR FUNC_DEF VAR ...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.ls = [] self.ls.append(homepage) self.hm = {} self.cur = 0 def visit(self, url: str) -> None: self.ls = self.ls[: self.cur + 1] self.ls.append(url) self.cur = len(self.ls) - 1 def back(se...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FUNC_DEF VAR ASSIGN VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER NONE FUNC_DEF VAR IF VAR VAR ASSIGN VAR NUMBER RETURN VAR NUMBER VAR VAR RETURN VAR VAR VAR FUNC_DEF VAR IF VAR ...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.history = [homepage] self.i = 0 def visit(self, url: str) -> None: self.history = self.history[0 : self.i + 1] self.history.append(url) self.i += 1 def back(self, steps: int) -> str: if self.i >=...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER FUNC_DEF VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER NONE FUNC_DEF VAR IF VAR VAR FOR VAR FUNC_CALL VAR VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR NUMBER RETURN VAR VAR VAR FUNC_DEF VAR IF BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NU...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.history = LinkedList(homepage, None, None) self.curr_page = self.history def visit(self, url: str) -> None: new_page = LinkedList(url, self.curr_page, None) self.curr_page.next = new_page self.curr_page = new...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR NONE NONE ASSIGN VAR VAR FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NONE ASSIGN VAR VAR ASSIGN VAR VAR NONE FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR NONE ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR RETURN VAR VAR FUNC_DEF VAR ASSIGN VAR NUMBER A...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.stack = [homepage] self.stack_position = 0 def visit(self, url: str) -> None: self.stack_position += 1 print('You are in "{}". Visit "{}"'.format(self.stack[-1], url)) while self.stack_position < len(self.sta...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER FUNC_DEF VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER VAR WHILE VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NONE FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN VA...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class Node: def __init__(self, data): self.next = None self.prev = None self.data = data class BrowserHistory: def __init__(self, homepage: str): self.head = Node(homepage) self.head.next = None self.head.prev = None self.curr = self.head def visi...
CLASS_DEF FUNC_DEF ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR VAR CLASS_DEF FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR VAR FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR NONE FUNC_DEF VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NONE ASSIGN VA...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.curr = homepage self.backw = [] self.forw = [] def visit(self, url: str) -> None: self.backw.append(self.curr) self.forw = [] self.curr = url def back(self, steps: int) -> str: for _ in r...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR NONE FUNC_DEF VAR FOR VAR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR RETURN VAR VAR FUNC_DEF VAR FOR VAR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR VAR ...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.currentIndex = 0 self.maxIndex = 0 self.history = {self.currentIndex: homepage} def visit(self, url: str) -> None: self.currentIndex += 1 self.history[self.currentIndex] = url self.maxIndex = self.cur...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT VAR VAR FUNC_DEF VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR NONE FUNC_DEF VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER VAR RETURN VAR VAR VAR FUNC_DEF VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR RETURN VAR VAR VAR
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BiLinkedNode: def __init__(self, val: str): self.val = val self.next = None self.prev = None class BrowserHistory: def __init__(self, homepage: str): self.currPage = BiLinkedNode(homepage) self.browseListLen = 1 self.currPageIdx = 0 def visit(self, ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR VAR ASSIGN VAR NONE ASSIGN VAR NONE CLASS_DEF FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NONE FUNC_DEF VAR WHILE VAR NUMBER ...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.history = [] self.forwardHistory = [] self.curr = homepage def visit(self, url: str) -> None: self.history.append(self.curr) self.curr = url self.forwardHistory = [] def back(self, steps: int) ->...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR FUNC_DEF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST NONE FUNC_DEF VAR IF VAR RETURN VAR ASSIGN VAR VAR ASSIGN VAR NONE WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR RETURN VAR VAR FUNC_DEF VAR ...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.back_stack = [] self.front_stack = [] self.curr = homepage def visit(self, url: str) -> None: self.front_stack = [] self.back_stack.append(self.curr) self.curr = url def back(self, steps: int) ->...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR FUNC_DEF VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NONE FUNC_DEF VAR FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR RETURN VAR VAR FUNC_DEF VAR FOR VAR F...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class ListNode: def __init__(self, x): self.val = x self.next = None self.prev = None class BrowserHistory: def __init__(self, homepage: str): self.root = ListNode(homepage) def visit(self, url: str) -> None: node = ListNode(url) node.prev = self.root ...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NONE ASSIGN VAR NONE CLASS_DEF FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR NONE FUNC_DEF VAR WHILE VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN VAR VAR FUNC_DEF VAR WHILE VAR VAR ASSIGN VAR VAR ...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.ls = [homepage] self.cur = 0 def visit(self, url: str) -> None: last = len(self.ls) - 1 while last != self.cur: self.ls.pop() last -= 1 self.ls.append(url) self.cur = len(self....
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER FUNC_DEF VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER NONE FUNC_DEF VAR WHILE VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR VAR VAR FUNC_D...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.list1 = [homepage] self.currentInd = 0 def visit(self, url: str) -> None: newList = self.list1[0 : self.currentInd + 1] newList.append(url) self.currentInd += 1 self.list1 = newList print((sel...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER FUNC_DEF VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR VAR NONE FUNC_DEF VAR WHILE VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR VAR VAR FUNC_DEF VAR WHILE VAR BIN_OP FUNC_CALL VAR...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.list = [] self.list.append(homepage) self.currentIndex = 0 def visit(self, url: str) -> None: self.currentIndex += 1 while self.currentIndex < len(self.list): self.list.pop() self.list.app...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_DEF VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NONE FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN VAR VAR VAR FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.pages = [homepage] self.curr = 0 def visit(self, url: str) -> None: self.pages = self.pages[: self.curr + 1] self.pages.append(url) self.curr = len(self.pages) - 1 print(self.pages) def back(self...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER FUNC_DEF VAR ASSIGN VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NONE FUNC_DEF VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER RETURN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN VAR VAR VAR ...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.urls = [] self.urls.append(homepage) self.i = 0 self.bound = 0 def visit(self, url: str) -> None: self.urls.append(url) self.i += 1 if self.i == len(self.urls): self.urls.append(ur...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR NONE FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR RETURN VAR VAR VAR FUNC_DEF ...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.history = [homepage] self.pointer = 0 def visit(self, url: str) -> None: if self.pointer < len(self.history) - 1: del self.history[self.pointer + 1 :] self.history.append(url) self.pointer = len(s...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER FUNC_DEF VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER NONE FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR VAR VAR FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR VAR...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.backwardStack = [homepage] self.forwardStack = [] def visit(self, url: str) -> None: self.backwardStack.append(url) self.forwardStack.clear() def back(self, steps: int) -> str: while len(self.backwardSta...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST VAR ASSIGN VAR LIST FUNC_DEF VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NONE FUNC_DEF VAR WHILE FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR NUMBER RETURN VAR NUMBER VAR FUNC_DEF VAR WHILE VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.history = [homepage] self.current = 0 def visit(self, url: str) -> None: self.history = self.history[: self.current + 1] self.history.append(url) self.current = len(self.history) - 1 def back(self, steps...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER FUNC_DEF VAR ASSIGN VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER NONE FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR RETURN VAR VAR VAR FUNC_DEF VAR IF BIN_OP VAR VAR BIN_OP FUNC_CALL ...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.forwardA = [] self.backward = [homepage] def visit(self, url: str) -> None: self.backward.append(url) self.forwardA = [] def forward(self, steps: int) -> str: i = 0 while len(self.forwardA) != 0 ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST ASSIGN VAR LIST VAR FUNC_DEF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST NONE FUNC_DEF VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR RETURN VAR NUMBER VAR FUNC_DEF VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VA...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.pointer = 0 self.histlen = 1 self.history = [homepage] def visit(self, url: str) -> None: self.history = self.history[: self.pointer + 1] + [url] self.pointer += 1 self.histlen = len(self.history) ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST VAR FUNC_DEF VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER LIST VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NONE FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER RETURN VAR VAR VAR FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BI...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage): self.history = [homepage] self.curr = 0 self.bound = 0 def visit(self, url): self.curr += 1 if self.curr == len(self.history): self.history.append(url) else: self.history[self.curr] = ur...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF VAR NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER RETURN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN VAR VAR
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.home = homepage self.history = [homepage] + [(0) for _ in range(5000)] self.curr_ind = 0 self.top = 0 def visit(self, url: str) -> None: self.history[self.curr_ind + 1] = url self.curr_ind += 1 ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NONE FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR RETURN VAR VAR VAR FUNC_DEF VAR ASSIGN VAR FUNC_CA...
You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: BrowserHistory(string homepage) Initializes the object with the homepage of the browser. void visit(st...
class BrowserHistory: def __init__(self, homepage: str): self.history_ = [homepage] self.count_ = 1 def visit(self, url: str) -> None: self.history_ = self.history_[: self.count_] self.history_.append(url) self.count_ += 1 def back(self, steps: int) -> str: ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER FUNC_DEF VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER NONE FUNC_DEF VAR IF VAR VAR VAR VAR RETURN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER RETURN VAR BIN_OP VAR NUMBER VAR FUNC_DEF VAR IF VAR BIN_OP FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR BIN_OP V...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): def rec(idx1, idx2, wild, pattern): if idx1 < 0 and idx2 < 0: return True if idx1 < 0 and idx2 >= 0: return False if idx1 >= 0 and idx2 < 0: for i in range(idx1 + 1): ...
CLASS_DEF FUNC_DEF FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING RETURN NUMBER RETURN NUMBER IF VAR VAR VAR VAR VAR VAR STRING RETURN FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR IF V...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, p, s): dp = [[(False) for i in range(len(s) + 1)] for j in range(len(p) + 1)] for i in reversed(range(len(dp))): for j in reversed(range(len(dp[0]))): if i == len(dp) - 1 and j == len(dp[0]) - 1: dp[i][j] = True ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR ...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): n = len(wild) m = len(pattern) dp = [[(False) for _ in range(m + 1)] for _ in range(n + 1)] dp[0][0] = True for j in range(1, m + 1): dp[0][j] = False for i in range(1, n + 1): flag = True ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBE...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): if self.findMatch(wild, pattern): return True else: return False def findMatch(self, first, second): if len(first) == 0 and len(second) == 0: return True if len(first) > 1 and first[0] == "*": ...
CLASS_DEF FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER STRING ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN V...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: dp = [[]] def util(self, string, pattern, i, j): if self.dp[i][j] != -1: return self.dp[i][j] if i == 0 and j == 0: return True if i == 0 and j > 0: return False if j == 0 and i > 0: for i in range(1, i + 1): ...
CLASS_DEF ASSIGN VAR LIST LIST FUNC_DEF IF VAR VAR VAR NUMBER RETURN VAR VAR VAR IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING RETURN NUMBER RETURN NUMBER IF VAR BIN_OP VAR NUMBER VAR ...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): prev = "" n = len(pattern) m = len(wild) dp = [([False] * n) for _ in range(m + 1)] for i in range(n): dp[0][i] = True c, j = 0, 0 for i in range(1, m + 1): for j in range(c, n): ...
CLASS_DEF FUNC_DEF ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VA...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): def wildmatch(a, b, n, m): if n < 0 and m < 0: return True if n < 0 and m > 0: return False if n > 0 and m < 0: for i in range(n): if a[i] != "*": ...
CLASS_DEF FUNC_DEF FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING RETURN NUMBER RETURN NUMBER IF VAR VAR VAR VAR VAR VAR STRING RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR STRING ...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def solve(self, i, j, pattern, wild, dp): if i < 0 and j < 0: return True if i >= 0 and j < 0: return False if i < 0 and j >= 0: for k in range(j + 1): if wild[k] != "*": return False return ...
CLASS_DEF FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING RETURN NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR IF VAR VAR VAR VAR VAR VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): n = len(pattern) m = len(wild) dp = [[(0) for i in range(m + 1)] for j in range(n + 1)] dp[0][0] = 1 i = 0 while i < m and wild[i] == "*": dp[0][i + 1] = 1 i += 1 for i in range(1, n + 1)...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VA...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): n = len(wild) m = len(pattern) dp = [([-1] * 1001) for i in range(1001)] def fun(i, j): if i < 0 and j < 0: return True if i < 0: return False if j < 0: ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR IF VAR VAR STRING ASSIGN VAR VAR VAR...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): def dfs(s1, s2, i, j): if i == len(s1) and j == len(s2): return True if i == len(s1): return False if j == len(s2): if s1[i] == "*": return dfs(s1, s2, i ...
CLASS_DEF FUNC_DEF FUNC_DEF IF VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR FUNC_CALL VAR VAR IF VAR VAR STRING RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR RETURN NUMBER IF VAR VAR STRING VAR VAR STRING VAR VAR VAR VAR RETURN NUMBER IF VAR VAR STRING RET...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, s, p): s = pattern p = wild m = len(s) n = len(p) dp = [(["."] * (n + 1)) for i in range(m + 1)] for i in range(m + 1): for j in range(n + 1): if i == 0 and j == 0: dp[i][j] = True ...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBE...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): if not wild or not pattern: return False m = len(pattern) n = len(wild) dp = [[(False) for _ in range(n + 1)] for _ in range(m + 1)] dp[0][0] = 1 for j in range(1, n + 1): dp[0][j] = wild[j - 1] ...
CLASS_DEF FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRIN...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): dp = [[(False) for i in range(len(pattern) + 1)] for i in range(len(wild) + 1)] def recursion(wild, pattern, n, m): if n < 0 and m < 0: return True if n < 0: return False if m < 0: ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING RETURN NUMBER ASSIGN VAR NUMBER VAR...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): j = 0 t = wild[0] for i in range(1, len(wild)): if wild[i - 1] == "*" and wild[i] == "*": continue else: t += wild[i] i = 0 wild = t wild += "0" pattern +=...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER STRING VAR VAR STRING VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR STRING VAR STRING WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR VAR VAR STRING VAR NUMBER VAR NUMBER IF...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def traverse(self, wild, wi, pattern, pi, dp): if wi == len(wild) and pi == len(pattern): return True if pi == len(pattern) and wild[wi] == "*" and wi == len(wild) - 1: return True if wi == len(wild) or pi == len(pattern): return False ...
CLASS_DEF FUNC_DEF IF VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR FUNC_CALL VAR VAR VAR VAR STRING VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR VAR VAR NONE RETURN VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): def fun(wild, pattern, d): if (wild, pattern) in d: return d[wild, pattern] if pattern == "" and wild == "": return True if wild == pattern: return True if patter...
CLASS_DEF FUNC_DEF FUNC_DEF IF VAR VAR VAR RETURN VAR VAR VAR IF VAR STRING VAR STRING RETURN NUMBER IF VAR VAR RETURN NUMBER IF VAR STRING FOR VAR VAR IF VAR STRING RETURN NUMBER RETURN NUMBER IF VAR STRING RETURN NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR ASSIGN VAR VAR VAR VAR...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
def recur(wild, pattern, n, m, i, j): if i < 0 and j < 0: return True elif i < 0 and j >= 0: return False elif i >= 0 and j < 0: flag = 0 for i in range(i, -1, -1): if wild[i] != "*": flag = 1 break if flag == 1: ...
FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER IF VAR VAR VAR VAR VAR VAR STRING RETURN FUNC_CALL VAR VAR VAR VAR VAR B...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): dp = [[(-1) for i in range(len(pattern))] for i in range(len(wild))] def rec(i, j): if i < 0 and j < 0: return True if i < 0 and j >= 0: return False if i >= 0 and j < 0: ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING RETURN NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER RETUR...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, p, s): n = len(s) def solve(s, p, i, j): if i < 0 and j < 0: return True if i >= 0 and j < 0: return False if i < 0 and j >= 0: for r in range(j + 1): if p[r] != ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING RETURN NUMBER RETURN NUMBER IF VAR VAR VAR VAR VAR VAR STRING RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR ...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
dp = [[-1] * 1001] * 1001 def rec(p, s, i, j): if i == -1 and j == -1: return 1 if j == -1: for x in range(i): if p[x] != "*": return 0 return 1 if i == -1: return 0 if dp[i][j] != -1: return dp[i][j] if s[j] == p[i] or p[i] == "?...
ASSIGN VAR BIN_OP LIST BIN_OP LIST NUMBER NUMBER NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING RETURN NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR IF VAR VAR VAR VAR VAR VAR STRING ASSIGN VAR VAR VAR FUNC_CAL...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def solve(self, s, t, i, j): if i >= 0 and j < 0: return 0 if i < 0 and j < 0: return 1 if s[i] != "?" and s[i] != "*" and s[i] != t[j]: return 0 if s[i] == "?" or s[i] == t[j]: return self.solve(s, t, i - 1, j - 1) ...
CLASS_DEF FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR VAR STRING VAR VAR STRING VAR VAR VAR VAR RETURN NUMBER IF VAR VAR STRING VAR VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUM...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, str1, str2): i = len(str1) j = len(str2) dp = {} def dfs(i, j): if i == 0 and j == 0: return True if j == 0: return True if i == 1 and str1[i - 1] == "*" else False if i == 0: ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN VAR NUMBER VAR BIN_OP VAR NUMBER STRING NUMBER NUMBER IF VAR NUMBER RETURN NUMBER IF VAR VAR VAR RETURN VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NU...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): dp = [([False] * (len(pattern) + 1)) for _ in range(len(wild) + 1)] dp[0][0] = True for i in range(1, len(wild) + 1): if wild[i - 1] == "*": dp[i][0] = dp[i - 1][0] for i in range(1, len(wild) + 1): ...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, pat, str): n = len(pat) m = len(str) dp = [[(False) for i in range(m + 1)] for j in range(n + 1)] for i in range(n + 1): for j in range(m + 1): if j == 0: if i == 0: dp[i][j] = Tr...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR BIN_OP VAR N...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): p = len(pattern) w = len(wild) dp = [[(False) for i in range(p + 1)] for j in range(w + 1)] dp[0][0] = True for j in range(1, w + 1): if wild[j - 1] == "*": dp[j][0] = dp[j - 1][0] for i in r...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR VAR NUMBER VAR BIN_OP VAR NUMBE...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): n = len(wild) m = len(pattern) def solve(i, j): if i == 0 and j == 0: return True if i <= 0 and j > 0: return False if j == 0 and i > 0: for k in range(1, i +...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER STRING RETURN NUMBER RETURN NUMBER IF VAR BIN_OP VAR NUMBER...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, w, p): m = len(w) n = len(p) dp = {} def fun(m, n): if m == 0 and n == 0: return 1 if n == 0: return 1 if m == 1 and w[m - 1] == "*" else 0 if m == 0: return 0 ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN VAR NUMBER VAR BIN_OP VAR NUMBER STRING NUMBER NUMBER IF VAR NUMBER RETURN NUMBER IF VAR VAR VAR RETURN VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NU...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
dp = [[-1] * 1001] * 1001 def rec(p, s, i, j): if i == -1 and j == -1: return 1 if j == -1: for x in range(i): if p[x] != "*": return 0 return 1 if i == -1: return 0 if s[j] == p[i] or p[i] == "?": return rec(p, s, i - 1, j - 1) i...
ASSIGN VAR BIN_OP LIST BIN_OP LIST NUMBER NUMBER NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING RETURN NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR VAR VAR VAR VAR VAR STRING RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF ...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, p, s): n = len(s) m = len(p) dp = [([-1] * (m + 1)) for i in range(n + 1)] def rec(dp, s, p, n, m): if n == 0: if m == 0 or p[:m].count("*") == m: return True if n == 0 or m == 0: ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER IF VAR NUMBER FUNC_CALL VAR VAR STRING VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER IF VAR BIN_OP VAR ...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, pattern, string): dp = [] for i in range(len(string) + 1): curr = [] for j in range(len(pattern) + 1): curr.append(-1) dp.append(curr) for i in range(1, len(string) + 1): dp[i][0] = False ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMB...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): i = len(wild) - 1 j = len(pattern) - 1 def wildd(i, j, wild, pattern): if i < 0 and j < 0: return True if i < 0 and j >= 0: return False if j < 0 and i >= 0: ...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING RETURN NUMBER RETURN NUMBER IF VAR VAR VAR VAR VAR V...
Given two strings wild and pattern where wild string may contain wild card characters and pattern string is a normal string. Determine if the two strings match. The following are the allowed wild card characters in first string :- * --> This character in string wild can be replaced by any sequence of characters, it can...
class Solution: def match(self, wild, pattern): m = len(wild) n = len(pattern) dp = [] for i in range(m): dp.append([-1] * n) def memo(dp, wild, pattern, i, j): if i == -1 and j == -1: return 1 if j == -1: ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST NUMBER VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING RETURN NUMBER RETURN NUMBER IF VAR NUMBER RETU...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def matrixMultiplication(self, N, arr): dp = [[(0) for j in range(len(arr))] for i in range(len(arr))] for i in range(len(arr) - 1, 0, -1): for j in range(i + 1, len(arr)): miniAnswer = float("inf") for k in range(i, j): ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_O...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def matrixMultiplication(self, N, arr): dp = [[(0) for i in range(N + 2)] for i in range(N + 2)] MAX = 1 << 33 for L in range(2, N): for i in range(1, N - L + 1): j = i + L - 1 dp[i][j] = MAX for k in range(i, j): ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
import sys class Solution: def matrixMultiplication(self, N, arr): m = [[(0) for x in range(N)] for x in range(N)] for i in range(1, N): m[i][i] = 0 for L in range(2, N): for i in range(1, N - L + 1): j = i + L - 1 m[i][j] = sys.maxs...
IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL V...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: dp = [] def gen(self, i, j, arr): if i == j: return 0 if self.dp[i][j] != -1: return self.dp[i][j] mini = 9999999999999 for k in range(i, j): ans = ( arr[i - 1] * arr[k] * arr[j] + self.gen(i, k,...
CLASS_DEF ASSIGN VAR LIST FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def matrixMultiplication(self, N, arr): dp = [[(-1) for i in range(N + 2)] for j in range(N + 2)] def solve(i, j): if i >= j: return 0 ans = 999999999 if dp[i][j] != -1: return dp[i][j] for k in range(i...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_O...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def matrixMultiplication(self, N, arr): dp = [[(-1) for _ in range(N)] for _ in range(N)] for i in range(1, N): dp[i][i] = 0 for i in range(N - 1, 0, -1): for j in range(i + 1, N): mini = float("inf") for k in range(i, ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BI...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def matrixMultiplication(self, N, arr): dp = [[(-1) for _ in range(len(arr))] for _ in range(len(arr))] return minMul(arr, 1, N - 1, dp) def minMul(arr, i, j, dp): if i == j: return 0 if dp[i][j] != -1: return dp[i][j] minn = float("inf") for k in r...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BI...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def matrixMultiplication(self, n, arr): dp = {} def fun(i=1, j=n - 1): if i == j: return 0 if (i, j) in dp: return dp[i, j] mini = float("inf") for k in range(i, j): res = arr[i - 1] * a...
CLASS_DEF FUNC_DEF ASSIGN VAR DICT FUNC_DEF NUMBER BIN_OP VAR NUMBER IF VAR VAR RETURN NUMBER IF VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def matrixMultiplication(self, N, arr): dp = [[(-1) for _ in range(N)] for _ in range(N)] return self.f(arr, 1, N - 1, dp) def f(self, arr, i, j, dp): if i >= j: return 0 if dp[i][j] != -1: return dp[i][j] res = float("inf") ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR V...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def matrixMultiplication(self, N, arr): dp = [[(-1) for i in range(N)] for j in range(N)] for i in range(N): dp[i][i] = 0 for i in range(N - 1, 0, -1): for j in range(i + 1, N): ans = 1000000000.0 for k in range(i, j): ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VA...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def matrixMultiplication(self, n, arr): dp = [[(0) for _ in range(n)] for _ in range(n)] for L in range(2, n + 1): for i in range(1, n - L + 1): j = i + L - 1 dp[i][j] = float("inf") for k in range(i, j): ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR FUNC_...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def solve(self, i, j, arr, dp): if i == j: return 0 if dp[i][j] != -1: return dp[i][j] minCost = float("inf") for k in range(i, j): cost = ( self.solve(i, k, arr, dp) + self.solve(k + 1, j, arr, dp) ...
CLASS_DEF FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR FUNC_CALL V...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def matrixMultiplication(self, N, arr): def findans(arr, start, end): if start == end: return 0 ans = float("inf") for k in range(start, end): ans = min( ans, arr[start - 1] * arr[k]...
CLASS_DEF FUNC_DEF FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR RETURN VAR ASSIGN VAR BIN_OP LIST FUNC_CALL ...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
import sys class Solution: def matrixMultiplication(self, N, arr): def fun(arr, i, j): if i == j: return 0 mini = sys.maxsize if dp[i][j] != -1: return dp[i][j] for k in range(i, j): tempans = ( ...
IMPORT CLASS_DEF FUNC_DEF FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR VAR IF VAR VAR VAR NUMBER RETURN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VA...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def ops(self, i, j, arr, dp): if i == j: return 0 if dp[i][j] != -1: ans = dp[i][j] return ans mini = 1000000000.0 for k in range(i, j): step1 = self.ops(i, k, arr, dp) step2 = self.ops(k + 1, j, arr, dp) ...
CLASS_DEF FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR RETURN VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR BI...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def matrixMultiplication(self, N, arr): dp = [([0] * N) for i in range(N)] for i in range(1, N): dp[i][i] = 0 for l in range(2, N): for i in range(1, N - l + 1): j = i + l - 1 dp[i][j] = 10000000000.0 fo...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def matrixMultiplication(self, N, arr): dp = [[(-1) for i in range(100)] for j in range(100)] def matrixChainMemoised(p, i, j): if i == j: return 0 if dp[i][j] != -1: return dp[i][j] dp[i][j] = float("inf") ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR FUN...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
import sys class Solution: def matrixMultiplication(self, N, arr): n = len(arr) dp = [([0] * n) for _ in range(n)] for i in range(n - 2, -1, -1): for j in range(i + 1, n): minn = sys.maxsize for k in range(i, j): temp = dp[i]...
IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER VAR BIN...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def matrixMultiplication(self, n, arr): dp = [[(-1) for i in range(n)] for j in range(n)] def answer(i, j): if i == j: return 0 mini = int(1000000000.0) if dp[i][j] != -1: return dp[i][j] for k in range...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUN...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def matrixMultiplication(self, N, arr): i, j = 0, len(arr) - 2 dp = [[(-1) for i in range(len(arr) - 1)] for j in range(len(arr) - 1)] res = self.mcm(arr, i, j, dp) return res def mcm(self, arr, i, j, dp): if i >= j: return 0 if dp[i]...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR AS...
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The efficient way is the one that involves the least number of multiplications. The dimensions of the matrices are given in an array arr[] of size N (such that N = number of matrices + 1) where the i^{th} matrix has the dime...
class Solution: def mem(self, dp, N, arr, i, j): if j - i <= 1: dp[i][j] = 0 return 0 if dp[i][j] != -1: return dp[i][j] cost = 2147483647 for k in range(i + 1, j): cost = min( cost, arr[i] * arr[k] * ar...
CLASS_DEF FUNC_DEF IF BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ...