636. Exclusive Time of Functions

On a single-threaded CPU, we execute a program containing n functions. Each function has a unique ID between 0 and n-1. Function calls are stored in a call stack: when a function call starts, its ID is pushed onto the stack, and when a function call ends, its ID is popped off the stack. The function whose ID is at the top of the stack is the current function being executed....

<span title='2022-01-30 00:00:00 +0000 UTC'>January 30, 2022</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;volyx

1305. All Elements in Two Binary Search Trees

Given two binary search trees root1 and root2. Return a list containing all the integers from both trees sorted in ascending order. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Example 1: Input: root1 = [2,1,4], root2 = [1,0,3] Output: [0,1,1,2,3,4] Example 2: Input: root1 = [0,-10,10], root2 = [5,1,7,0,2] Output: [-10,0,0,1,2,5,7,10] Example 3: Input: root1 = [], root2 = [5,1,7,0,2] Output: [0,1,2,5,7] Example 4: Input: root1 = [0,-10,10], root2 = [] Output: [-10,0,10] 1 2 3 4 Example 5: Input: root1 = [1,null,8], root2 = [8,1] Output: [1,1,8,8] Constraints:...

<span title='2021-10-28 00:00:00 +0000 UTC'>October 28, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

173. Binary Search Tree Iterator

Implement the BSTIterator class that represents an iterator over the in-order traversal of a binary search tree (BST): BSTIterator(TreeNode root) Initializes an object of the BSTIterator class. The root of the BST is given as part of the constructor. The pointer should be initialized to a non-existent number smaller than any element in the BST. boolean hasNext() Returns true if there exists a number in the traversal to the right of the pointer, otherwise returns false....

<span title='2021-10-28 00:00:00 +0000 UTC'>October 28, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

71. Simplify Path

71. Simplify Path Given a string path, which is an absolute path (starting with a slash ‘/’) to a file or directory in a Unix-style file system, convert it to the simplified canonical path. In a Unix-style file system, a period ‘.’ refers to the current directory, a double period ‘..’ refers to the directory up a level, and any multiple consecutive slashes (i.e. ‘//’) are treated as a single slash ‘/’....

<span title='2021-07-26 00:00:00 +0000 UTC'>July 26, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

496. Next Greater Element I

496. Next Greater Element I The next greater element of some element x in an array is the first greater element that is to the right of x in the same array. You are given two distinct 0-indexed integer arrays nums1 and nums2, where nums1 is a subset of nums2. For each 0 <= i < nums1.length, find the index j such that nums1[i] == nums2[j] and determine the next greater element of nums2[j] in nums2....

<span title='2021-07-15 00:00:00 +0000 UTC'>July 15, 2021</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;volyx

503. Next Greater Element II

503. Next Greater Element II Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in nums. The next greater number of a number x is the first greater number to its traversing-order next in the array, which means you could search circularly to find its next greater number. If it doesn’t exist, return -1 for this number....

<span title='2021-07-15 00:00:00 +0000 UTC'>July 15, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1441. Build an Array With Stack Operations

1441. Build an Array With Stack Operations Given an array target and an integer n. In each iteration, you will read a number from list = {1,2,3…, n}. Build the target array using the following operations: Push: Read a new element from the beginning list, and push it in the array. Pop: delete the last element of the array. If the target array is already built, stop reading more elements. Return the operations to build the target array....

<span title='2021-03-27 00:00:00 +0000 UTC'>March 27, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

199. Binary Tree Right Side View

199. Binary Tree Right Side View Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. 1 2 3 4 Example 1: Input: root = [1,2,3,null,5,null,4] Output: [1,3,4] 1 2 3 4 Example 2: Input: root = [1,null,3] Output: [1,3] 1 2 3 4 Example 3: Input: root = [] Output: [] Constraints:...

<span title='2021-03-27 00:00:00 +0000 UTC'>March 27, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

150. Evaluate Reverse Polish Notation

![https://leetcode.com/problems/evaluate-reverse-polish-notation/] Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Note: Division between two integers should truncate toward zero. The given RPN expression is always valid. That means the expression would always evaluate to a result and there won’t be any divide by zero operation. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 Example 1: Input: ["2", "1", "+", "3", "*"] Output: 9 Explanation: ((2 + 1) * 3) = 9 Example 2: Input: ["4", "13", "5", "/", "+"] Output: 6 Explanation: (4 + (13 / 5)) = 6 Example 3: Input: ["10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+"] Output: 22 Explanation: ((10 * (6 / ((9 + 3) * -11))) + 17) + 5 = ((10 * (6 / (12 * -11))) + 17) + 5 = ((10 * (6 / -132)) + 17) + 5 = ((10 * 0) + 17) + 5 = (0 + 17) + 5 = 17 + 5 = 22 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 class Solution { public int evalRPN(String[] tokens) { int[] stack = new int[tokens....

<span title='2021-02-22 00:00:00 +0000 UTC'>February 22, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1598. Crawler Log Folder

![https://leetcode.com/problems/crawler-log-folder/] The Leetcode file system keeps a log each time some user performs a change folder operation. The operations are described below: “../” : Move to the parent folder of the current folder. (If you are already in the main folder, remain in the same folder). “./” : Remain in the same folder. “x/” : Move to the child folder named x (This folder is guaranteed to always exist). You are given a list of strings logs where logs[i] is the operation performed by the user at the ith step....

<span title='2021-02-22 00:00:00 +0000 UTC'>February 22, 2021</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;volyx

1598. Crawler Log Folder

![https://leetcode.com/problems/crawler-log-folder/] The Leetcode file system keeps a log each time some user performs a change folder operation. The operations are described below: “../” : Move to the parent folder of the current folder. (If you are already in the main folder, remain in the same folder). “./” : Remain in the same folder. “x/” : Move to the child folder named x (This folder is guaranteed to always exist). You are given a list of strings logs where logs[i] is the operation performed by the user at the ith step....

<span title='2021-02-22 00:00:00 +0000 UTC'>February 22, 2021</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;volyx

1021. Remove Outermost Parentheses

![https://leetcode.com/problems/remove-outermost-parentheses/] A valid parentheses string is either empty (""), “(” + A + “)”, or A + B, where A and B are valid parentheses strings, and + represents string concatenation. For example, “”, “()”, “(())()”, and “(()(()))” are all valid parentheses strings. A valid parentheses string S is primitive if it is nonempty, and there does not exist a way to split it into S = A+B, with A and B nonempty valid parentheses strings....

<span title='2021-02-20 00:00:00 +0000 UTC'>February 20, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

1047. Remove All Adjacent Duplicates In String

Given a string S of lowercase letters, a duplicate removal consists of choosing two adjacent and equal letters, and removing them. We repeatedly make duplicate removals on S until we no longer can. Return the final string after all such duplicate removals have been made. It is guaranteed the answer is unique. 1 2 3 4 5 6 Example 1: Input: "abbaca" Output: "ca" Explanation: For example, in "abbaca" we could remove "bb" since the letters are adjacent and equal, and this is the only possible move....

<span title='2021-02-20 00:00:00 +0000 UTC'>February 20, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1209. Remove All Adjacent Duplicates in String II

![https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii/] Given a string s, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them causing the left and the right side of the deleted substring to concatenate together. We repeatedly make k duplicate removals on s until we no longer can. Return the final string after all such duplicate removals have been made. It is guaranteed that the answer is unique. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Example 1: Input: s = "abcd", k = 2 Output: "abcd" Explanation: There's nothing to delete....

<span title='2021-02-20 00:00:00 +0000 UTC'>February 20, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

155. Min Stack

![https://leetcode.com/problems/min-stack/] Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the top element. getMin() – Retrieve the minimum element in the stack. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Example 1: Input ["MinStack","push","push","push","getMin","pop","top","getMin"] [[],[-2],[0],[-3],[],[],[],[]] Output [null,null,null,null,-3,null,0,-2] Explanation MinStack minStack = new MinStack(); minStack....

<span title='2021-02-20 00:00:00 +0000 UTC'>February 20, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx