Check If a String Contains All Binary Codes of Size K

Given a binary string s and an integer k. Return True if every binary code of length k is a substring of s. Otherwise, return False. Example 1: 1 2 3 Input: s = "00110110", k = 2 Output: true Explanation: The binary codes of length 2 are "00", "01", "10" and "11". They can be all found as substrings at indicies 0, 1, 3 and 2 respectively. Example 2:...

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

Daily Temperatures

Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead. For example, given the list of temperatures T = [73, 74, 75, 71, 69, 72, 76, 73], your output should be [1, 1, 4, 2, 1, 1, 0, 0]....

<span title='2020-07-16 00:00:00 +0000 UTC'>July 16, 2020</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;volyx

Prison Cells After N Days

There are 8 prison cells in a row, and each cell is either occupied or vacant. Each day, whether the cell is occupied or vacant changes according to the following rules: If a cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied. Otherwise, it becomes vacant. (Note that because the prison is a row, the first and the last cells in the row can’t have two adjacent neighbors....

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

Sort Array By Parity

Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A. You may return any answer array that satisfies this condition. 1 2 3 4 5 Example 1: Input: [3,1,2,4] Output: [2,4,3,1] The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted. Note: 1 <= A.length <= 5000 0 <= A[i] <= 5000 Solution: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 class Solution { public int[] sortArrayByParity(int[] A) { int n = A....

<span title='2020-06-19 00:00:00 +0000 UTC'>June 19, 2020</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;volyx

Maximum Sum Circular Subarray

Given a circular array C of integers represented by A, find the maximum possible sum of a non-empty subarray of C. Here, a circular array means the end of the array connects to the beginning of the array. (Formally, C[i] = A[i] when 0 <= i < A.length, and C[i+A.length] = C[i] when i >= 0.) Also, a subarray may only include each element of the fixed buffer A at most once....

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

Remove K Digits

Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: The length of num is less than 10002 and will be ≥ k. The given num does not contain any leading zero. Example 1: 1 2 3 Input: num = "1432219", k = 3 Output: "1219" Explanation: Remove the three digits 4, 3, and 2 to form the new number 1219 which is the smallest....

<span title='2020-06-01 00:00:00 +0000 UTC'>June 1, 2020</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

Binary Tree Maximum Path Sum

Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need to go through the root. Example 1: 1 2 3 4 5 6 7 Input: [1,2,3] 1 / \ 2 3 Output: 6 Example 2:...

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

Perform String Shifts

You are given a string s containing lowercase English letters, and a matrix shift, where shift[i] = [direction, amount]: direction can be 0 (for left shift) or 1 (for right shift). amount is the amount by which string s is to be shifted. A left shift by 1 means remove the first character of s and append it to the end. Similarly, a right shift by 1 means remove the last character of s and add it to the beginning....

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

Contiguous Array

Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1. Example 1: 1 2 3 4 5 6 7 8 9 Input: [0,1] Output: 2 Explanation: [0, 1] is the longest contiguous subarray with equal number of 0 and 1. Example 2: ```txt Input: [0,1,0] Output: 2 Explanation: [0, 1] (or [1, 0]) is a longest contiguous subarray with equal number of 0 and 1....

<span title='2020-04-17 00:00:00 +0000 UTC'>April 17, 2020</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;volyx

Diameter of Binary Tree

Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. Example: Given a binary tree 1 2 3 4 5 1 / \ 2 3 / \ 4 5 Return 3, which is the length of the path [4,2,1,3] or [5,2,1,3]....

<span title='2020-04-15 00:00:00 +0000 UTC'>April 15, 2020</span>&nbsp;·&nbsp;6 min&nbsp;·&nbsp;volyx