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

547. Number of Provinces

![https://leetcode.com/problems/number-of-provinces/] There are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and city b is connected directly with city c, then city a is connected indirectly with city c. A province is a group of directly or indirectly connected cities and no other cities outside of the group. You are given an n x n matrix isConnected where isConnected[i][j] = 1 if the ith city and the jth city are directly connected, and isConnected[i][j] = 0 otherwise....

<span title='2021-01-16 00:00:00 +0000 UTC'>January 16, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

684. Redundant Connection

![https://leetcode.com/problems/redundant-connection/] In this problem, a tree is an undirected graph that is connected and has no cycles. The given input is a graph that started as a tree with N nodes (with distinct values 1, 2, …, N), with one additional edge added. The added edge has two different vertices chosen from 1 to N, and was not an edge that already existed. The resulting graph is given as a 2D-array of edges....

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

1010. Pairs of Songs With Total Durations Divisible by 60

You are given a list of songs where the ith song has a duration of time[i] seconds. Return the number of pairs of songs for which their total duration in seconds is divisible by 60. Formally, we want the number of indices i, j such that i < j with (time[i] + time[j]) % 60 == 0. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Example 1: Input: time = [30,20,150,100,40] Output: 3 Explanation: Three pairs have a total duration divisible by 60: (time[0] = 30, time[2] = 150): total duration 180 (time[1] = 20, time[3] = 100): total duration 120 (time[1] = 20, time[4] = 40): total duration 60 Example 2: Input: time = [60,60,60] Output: 3 Explanation: All three pairs have a total duration of 120, which is divisible by 60....

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

Lowest Common Ancestor of a Binary Tree

Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).” 1 2 3 4 5 Example 1: Input: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1 Output: 3 Explanation: The LCA of nodes 5 and 1 is 3....

<span title='2020-11-12 00:00:00 +0000 UTC'>November 12, 2020</span>&nbsp;·&nbsp;5 min&nbsp;·&nbsp;volyx

Regions Cut By Slashes

An a N x N grid composed of 1 x 1 squares, each 1 x 1 square consists of a /, , or blank space. These characters divide the square into contiguous regions. (Note that backslash characters are escaped, so a \ is represented as “\”.) Return the number of regions. Example 1: 1 2 3 4 5 6 7 Input: [ " /", "/ " ] Output: 2 Explanation: The 2x2 grid is as follows: Example 2:...

<span title='2020-11-08 00:00:00 +0000 UTC'>November 8, 2020</span>&nbsp;·&nbsp;7 min&nbsp;·&nbsp;volyx

Longest Substring Without Repeating Characters

Given a string s, find the length of the longest substring without repeating characters. Example 1: 1 2 3 Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: 1 2 3 Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: 1 2 3 4 Input: s = "pwwkew" Output: 3 Explanation: The answer is "wke", with the length of 3....

<span title='2020-11-07 00:00:00 +0000 UTC'>November 7, 2020</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

Pow(x, n)

Implement pow(x, n), which calculates x raised to the power n (i.e. xn). Example 1: Input: x = 2.00000, n = 10 Output: 1024.00000 Example 2: Input: x = 2.10000, n = 3 Output: 9.26100 Example 3: Input: x = 2.00000, n = -2 Output: 0.25000 Explanation: 2-2 = 1/22 = 1/4 = 0.25 Constraints: -100.0 < x < 100.0 -231 <= n <= 231-1 -104 <= xn <= 104...

<span title='2020-10-27 00:00:00 +0000 UTC'>October 27, 2020</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;volyx

Binary Tree Zigzag Level Order Traversal

Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given binary tree [3,9,20,null,null,15,7], 1 2 3 4 5 3 / \ 9 20 / \ 15 7 return its zigzag level order traversal as: 1 2 3 4 5 [ [3], [20,9], [15,7] ] Solution: 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 /** * Definition for a binary tree node....

<span title='2020-10-21 00:00:00 +0000 UTC'>October 21, 2020</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;volyx

Top K Frequent Elements

Given a non-empty array of integers, return the k most frequent elements. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input: nums = [1], k = 1 Output: [1] Note: You may assume k is always valid, 1 ≤ k ≤ number of unique elements. Your algorithm’s time complexity must be better than O(n log n), where n is the array’s size. It’s guaranteed that the answer is unique, in other words the set of the top k frequent elements is unique....

<span title='2020-10-18 00:00:00 +0000 UTC'>October 18, 2020</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

Time Needed to Inform All Employees

A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company has is the one with headID. Each employee has one direct manager given in the manager array where manager[i] is the direct manager of the i-th employee, manager[headID] = -1. Also it’s guaranteed that the subordination relationships have a tree structure. The head of the company wants to inform all the employees of the company of an urgent piece of news....

<span title='2020-09-16 00:00:00 +0000 UTC'>September 16, 2020</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

Flip Equivalent Binary Trees

For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees. A binary tree X is flip equivalent to a binary tree Y if and only if we can make X equal to Y after some number of flip operations. Given the roots of two binary trees root1 and root2, return true if the two trees are flip equivelent or false otherwise....

<span title='2020-09-07 00:00:00 +0000 UTC'>September 7, 2020</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

Triangle

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle 1 2 3 4 5 6 [ [2], [3,4], [6,5,7], [4,1,8,3] ] The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11). Note: Bonus point if you are able to do this using only O(n) extra space, where n is the total number of rows in the triangle....

<span title='2020-09-05 00:00:00 +0000 UTC'>September 5, 2020</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx