This is a problem from Leetcode - Count Square Submatrices with All Ones.

Given a m * n matrix of ones and zeros, return how many square submatrices have all ones.

- Dec 6, 2019...more
## Number of Burgers with No Waste of Ingredients

Dec 4, 2019...moreThis is a problem from Leetcode - Number of Burgers with No Waste of Ingredients.

Given two integers tomatoSlices and cheeseSlices. The ingredients of different burgers are as follows:

- Jumbo Burger: 4 tomato slices and 1 cheese slice.
- Small Burger: 2 Tomato slices and 1 cheese slice.

Return [total_jumbo, total_small] so that the number of remaining tomatoSlices equal to 0 and the number of remaining cheeseSlices equal to 0. If it is not possible to make the remaining tomatoSlices and cheeseSlices equal to 0 return [].

## Find Winner on a Tic Tac Toe Game

Dec 3, 2019...moreThis is a problem from Leetcode - Find Winner on a Tic Tac Toe Game.

Tic-tac-toe is played by two players A and B on a 3 x 3 grid.

Here are the rules of Tic-Tac-Toe:

- Players take turns placing characters into empty squares (“ “).
- The first player A always places “X” characters, while the second player B always places “O” characters.
- “X” and “O” characters are always placed into empty squares, never on filled ones.
- The game ends when there are 3 of the same (non-empty) character filling any row, column, or diagonal.
- The game also ends if all squares are non-empty.
- No more moves can be played if the game is over.

Given an array moves where each element is another array of size 2 corresponding to the row and column of the grid where they mark their respective character in the order in which A and B play.

Return the winner of the game if it exists (A or B), in case the game ends in a draw return “Draw”, if there are still movements to play return “Pending”.

You can assume that moves is valid (It follows the rules of Tic-Tac-Toe), the grid is initially empty and A will play first.

## Count Servers that Communicate

Dec 2, 2019...moreThis is a problem from Leetcode - Count Servers that Communicate.

You are given a map of a server center, represented as a m * n integer matrix grid, where 1 means that on that cell there is a server and 0 means that it is no server. Two servers are said to communicate if they are on the same row or on the same column.

Return the number of servers that communicate with any other server.

## Hexspeak

Dec 1, 2019...moreThis is a problem from Leetcode - Hexspeak.

A decimal number can be converted to its Hexspeak representation by first converting it to an uppercase hexadecimal string, then replacing all occurrences of the digit 0 with the letter O, and the digit 1 with the letter I. Such a representation is valid if and only if it consists only of the letters in the set {“A”, “B”, “C”, “D”, “E”, “F”, “I”, “O”}.

Given a string num representing a decimal integer N, return the Hexspeak representation of N if it is valid, otherwise return “ERROR”.

## Minimum Time Visiting All Points

Nov 30, 2019...moreThis is a problem from Leetcode - Minimum Time Visiting All Points.

On a plane there are n points with integer coordinates points[i] = [xi, yi]. Your task is to find the minimum time in seconds to visit all points.

You can move according to the next rules:

- In one second always you can either move vertically, horizontally by one unit or diagonally (it means to move one unit vertically and one unit horizontally in one second).
- You have to visit the points in the same order as they appear in the array.

## Count Number of Nice Subarrays

Nov 21, 2019...moreThis is a problem from Leetcode - Count Number of Nice Subarrays.

Given an array of integers nums and an integer k. A subarray is called nice if there are k odd numbers on it.

Return the number of nice sub-arrays.

## Minimum Remove to Make Valid Parentheses

Nov 20, 2019...moreThis is a problem from Leetcode - 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.

## Number of Closed Islands

Nov 19, 2019...moreThis is a problem from Leetcode - Number of Closed Islands.

Given a 2D grid consists of 0s (land) and 1s (water). An island is a maximal 4-directionally connected group of 0s and a closed island is an island totally (all left, top, right, bottom) surrounded by 1s.

Return the number of closed islands.

## Find Elements in a Contaminated Binary Tree

Nov 18, 2019...moreThis is a problem from Leetcode - Find Elements in a Contaminated Binary Tree.

Given a binary tree with the following rules:

- root.val == 0
- If treeNode.val == x and treeNode.left != null, then treeNode.left.val == 2 * x + 1
- If treeNode.val == x and treeNode.right != null, then treeNode.right.val == 2 * x + 2

Now the binary tree is contaminated, which means all treeNode.val have been changed to -1.

You need to first recover the binary tree and then implement the FindElements class:

- FindElements(TreeNode* root) Initializes the object with a contamined binary tree, you need to recover it first.
- bool find(int target) Return if the target value exists in the recovered binary tree.