227. Basic Calculator II

![https://leetcode.com/problems/basic-calculator-ii/] Given a string s which represents an expression, evaluate this expression and return its value. The integer division should truncate toward zero. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Example 1: Input: s = "3+2*2" Output: 7 Example 2: Input: s = " 3/2 " Output: 1 Example 3: Input: s = " 3+5 / 2 " Output: 5 Constraints: 1 <= s....

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

844. Backspace String Compare

![https://leetcode.com/problems/backspace-string-compare/] Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. Note that after backspacing an empty text, the text will continue empty. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Example 1: Input: S = "ab#c", T = "ad#c" Output: true Explanation: Both S and T become "ac"....

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

682. Baseball Game

ou are keeping score for a baseball game with strange rules. The game consists of several rounds, where the scores of past rounds may affect future rounds’ scores. At the beginning of the game, you start with an empty record. You are given a list of strings ops, where ops[i] is the ith operation you must apply to the record and is one of the following: An integer x - Record a new score of x....

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

921. Minimum Add to Make Parentheses Valid

![https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses/] Given a string s of ‘(’ , ‘)’ and lowercase English characters. Your task is to remove the minimum number of parentheses ( ‘(’ or ‘)’, in any positions ) so that the resulting parentheses string is valid and return any valid string. Formally, a parentheses string is valid if and only if: It is the empty string, contains only lowercase characters, or It can be written as AB (A concatenated with B), where A and B are valid strings, or It can be written as (A), where A is a valid string....

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

682. Baseball Game

![https://leetcode.com/problems/baseball-game/] You are keeping score for a baseball game with strange rules. The game consists of several rounds, where the scores of past rounds may affect future rounds’ scores. At the beginning of the game, you start with an empty record. You are given a list of strings ops, where ops[i] is the ith operation you must apply to the record and is one of the following: An integer x - Record a new score of x....

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

128. Longest Consecutive Sequence

![https://leetcode.com/problems/longest-consecutive-sequence/] Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. 1 2 3 4 5 6 7 8 9 10 Example 1: Input: nums = [100,4,200,1,3,2] Output: 4 Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4. Example 2: Input: nums = [0,3,7,2,5,8,4,6,0,1] Output: 9 Constraints: 0 <= nums.length <= 104 -109 <= nums[i] <= 109 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 class Solution { public int longestConsecutive(int[] nums) { Map<Integer, Integer> valueToIndex = new HashMap<>(); UF uf = new UF(nums....

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

721. Accounts Merge

![https://leetcode.com/problems/accounts-merge/] Given a list accounts, each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails representing emails of the account. Now, we would like to merge these accounts. Two accounts definitely belong to the same person if there is some email that is common to both accounts. Note that even if two accounts have the same name, they may belong to different people as people could have the same name....

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

1202. Smallest String With Swaps

![https://leetcode.com/problems/smallest-string-with-swaps/] You are given a string s, and an array of pairs of indices in the string pairs where pairs[i] = [a, b] indicates 2 indices(0-indexed) of the string. You can swap the characters at any pair of indices in the given pairs any number of times. Return the lexicographically smallest string that s can be changed to after using the swaps. 1 2 3 4 5 6 7 Example 1: Input: s = "dcab", pairs = [[0,3],[1,2]] Output: "bacd" Explaination: Swap s[0] and s[3], s = "bcad" Swap s[1] and s[2], s = "bacd" 1 2 3 4 5 6 7 8 Example 2: Input: s = "dcab", pairs = [[0,3],[1,2],[0,2]] Output: "abcd" Explaination: Swap s[0] and s[3], s = "bcad" Swap s[0] and s[2], s = "acbd" Swap s[1] and s[2], s = "abcd" 1 2 3 4 5 6 7 8 Example 3: Input: s = "cba", pairs = [[0,1],[1,2]] Output: "abc" Explaination: Swap s[0] and s[1], s = "bca" Swap s[1] and s[2], s = "bac" Swap s[0] and s[1], s = "abc" Constraints:...

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

785. Is Graph Bipartite?

![https://leetcode.com/problems/is-graph-bipartite/] Given an undirected graph, return true if and only if it is bipartite. Recall that a graph is bipartite if we can split its set of nodes into two independent subsets A and B, such that every edge in the graph has one node in A and another node in B. The graph is given in the following form: graph[i] is a list of indexes j for which the edge between nodes i and j exists....

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

1496. Path Crossing

![https://leetcode.com/problems/path-crossing/] Given a string path, where path[i] = ‘N’, ‘S’, ‘E’ or ‘W’, each representing moving one unit north, south, east, or west, respectively. You start at the origin (0, 0) on a 2D plane and walk on the path specified by path. Return True if the path crosses itself at any point, that is, if at any time you are on a location you’ve previously visited. Return False otherwise....

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

990. Satisfiability of Equality Equations

![https://leetcode.com/problems/satisfiability-of-equality-equations/] Given an array equations of strings that represent relationships between variables, each string equations[i] has length 4 and takes one of two different forms: “a==b” or “a!=b”. Here, a and b are lowercase letters (not necessarily different) that represent one-letter variable names. Return true if and only if it is possible to assign integers to variable names so as to satisfy all the given equations. 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 Example 1: Input: ["a==b","b!...

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

130. Surrounded Regions

![https://leetcode.com/problems/surrounded-regions/] Given a 2D board containing ‘X’ and ‘O’ (the letter O), capture all regions surrounded by ‘X’. A region is captured by flipping all ‘O’s into ‘X’s in that surrounded region. 1 2 3 4 5 6 7 8 9 10 11 12 13 Example: X X X X X O O X X X O X X O X X After running your function, the board should be: X X X X X X X X X X X X X O X X Explanation:...

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

947. Most Stones Removed with Same Row or Column

![https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/] On a 2D plane, we place n stones at some integer coordinate points. Each coordinate point may have at most one stone. A stone can be removed if it shares either the same row or the same column as another stone that has not been removed. Given an array stones of length n where stones[i] = [xi, yi] represents the location of the ith stone, return the largest possible number of stones that can be removed....

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

773. Sliding Puzzle

![https://leetcode.com/problems/sliding-puzzle/] On a 2x3 board, there are 5 tiles represented by the integers 1 through 5, and an empty square represented by 0. A move consists of choosing 0 and a 4-directionally adjacent number and swapping it. The state of the board is solved if and only if the board is [[1,2,3],[4,5,0]]. Given a puzzle board, return the least number of moves required so that the state of the board is solved....

<span title='2021-02-07 00:00:00 +0000 UTC'>February 7, 2021</span>&nbsp;·&nbsp;5 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-01-26 00:00:00 +0000 UTC'>January 26, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx