939. Minimum Area Rectangle

You are given an array of points in the X-Y plane points where points[i] = [xi, yi]. Return the minimum area of a rectangle formed from these points, with sides parallel to the X and Y axes. If there is not any such rectangle, return 0. 1 2 3 4 Example 1: Input: points = [[1,1],[1,3],[3,1],[3,3],[2,2]] Output: 4 1 2 3 4 Example 2: Input: points = [[1,1],[1,3],[3,1],[3,3],[4,1],[4,3]] Output: 2 Constraints:...

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

736. Parse Lisp Expression

You are given a string expression representing a Lisp-like expression to return the integer value of. The syntax for these expressions is given as follows. -An expression is either an integer, let expression, add expression, mult expression, or an assigned variable. Expressions always evaluate to a single integer. (An integer could be positive or negative.) A let expression takes the form “(let v1 e1 v2 e2 … vn en expr)”, where let is always the string “let”, then there are one or more pairs of alternating variables and expressions, meaning that the first variable v1 is assigned the value of the expression e1, the second variable v2 is assigned the value of the expression e2, and so on sequentially; and then the value of this let expression is the value of the expression expr....

<span title='2021-12-11 00:00:00 +0000 UTC'>December 11, 2021</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;volyx

472. Concatenated Words

Given an array of strings words (without duplicates), return all the concatenated words in the given list of words. A concatenated word is defined as a string that is comprised entirely of at least two shorter words in the given array. 1 2 3 4 5 6 7 8 9 10 11 12 Example 1: Input: words = ["cat","cats","catsdogcats","dog","dogcatsdog","hippopotamuses","rat","ratcatdogcat"] Output: ["catsdogcats","dogcatsdog","ratcatdogcat"] Explanation: "catsdogcats" can be concatenated by "cats", "dog" and "cats"; "dogcatsdog" can be concatenated by "dog", "cats" and "dog"; "ratcatdogcat" can be concatenated by "rat", "cat", "dog" and "cat"....

<span title='2021-12-10 00:00:00 +0000 UTC'>December 10, 2021</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;volyx

1423. Maximum Points You Can Obtain from Cards

There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints. In one step, you can take one card from the beginning or from the end of the row. You have to take exactly k cards. Your score is the sum of the points of the cards you have taken. Given the integer array cardPoints and the integer k, return the maximum score you can obtain....

<span title='2021-12-06 00:00:00 +0000 UTC'>December 6, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

1136. Parallel Courses

You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given an array relations where relations[i] = [prevCoursei, nextCoursei], representing a prerequisite relationship between course prevCoursei and course nextCoursei: course prevCoursei has to be taken before course nextCoursei. In one semester, you can take any number of courses as long as you have taken all the prerequisites in the previous semester for the courses you are taking....

<span title='2021-11-30 00:00:00 +0000 UTC'>November 30, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

427. Construct Quad Tree

Given a n * n matrix grid of 0’s and 1’s only. We want to represent the grid with a Quad-Tree. Return the root of the Quad-Tree representing the grid. Notice that you can assign the value of a node to True or False when isLeaf is False, and both are accepted in the answer. A Quad-Tree is a tree data structure in which each internal node has exactly four children....

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

48. Rotate Image

You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation. 1 2 3 4 Example 1: Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [[7,4,1],[8,5,2],[9,6,3]] 1 2 3 4 Example 2: Input: matrix = [[5,1,9,11],[2,4,8,10],[13,3,6,7],[15,14,12,16]] Output: [[15,13,2,5],[14,3,4,1],[12,6,8,9],[16,7,10,11]] 1 2 3 4 Example 3: Input: matrix = [[1]] Output: [[1]] 1 2 3 4 Example 4: Input: matrix = [[1,2],[3,4]] Output: [[3,1],[4,2]] Constraints:...

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

332. Reconstruct Itinerary

You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it. All of the tickets belong to a man who departs from “JFK”, thus, the itinerary must begin with “JFK”. If there are multiple valid itineraries, you should return the itinerary that has the smallest lexical order when read as a single string....

<span title='2021-11-29 00:00:00 +0000 UTC'>November 29, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

655. Print Binary Tree

Given the root of a binary tree, construct a 0-indexed m x n string matrix res that represents a formatted layout of the tree. The formatted layout matrix should be constructed using the following rules: The height of the tree is height and the number of rows m should be equal to height + 1. The number of columns n should be equal to 2height+1 - 1. Place the root node in the middle of the top row (more formally, at location res[0][(n-1)/2])....

<span title='2021-11-29 00:00:00 +0000 UTC'>November 29, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

267. Palindrome Permutation II

Given a string s, return all the palindromic permutations (without duplicates) of it. You may return the answer in any order. If s has no palindromic permutation, return an empty list. 1 2 3 4 5 6 7 8 9 Example 1: Input: s = "aabb" Output: ["abba","baab"] Example 2: Input: s = "abc" Output: [] Constraints: 1 <= s.length <= 16 s consists of only lowercase English letters. 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 50 51 52 53 54 55 56 57 58 59 class Solution { public List<String> generatePalindromes(String s) { Set<String> res = new HashSet<>(); int[] freq = new int[256]; int count = 0; for (char c : s....

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

409. Longest Palindrome

Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters. Letters are case sensitive, for example, “Aa” is not considered a palindrome here. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Example 1: Input: s = "abccccdd" Output: 7 Explanation: One longest palindrome that can be built is "dccaccd", whose length is 7....

<span title='2021-11-28 00:00:00 +0000 UTC'>November 28, 2021</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;volyx

266. Palindrome Permutation

Given a string s, return true if a permutation of the string could form a palindrome. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Example 1: Input: s = "code" Output: false Example 2: Input: s = "aab" Output: true Example 3: Input: s = "carerac" Output: true Constraints: 1 <= s.length <= 5000 s consists of only lowercase English letters. Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 class Solution { public boolean canPermutePalindrome(String s) { int[] freq = new int[256]; for (char c: s....

<span title='2021-11-27 00:00:00 +0000 UTC'>November 27, 2021</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;volyx

286. Walls and Gates

You are given an m x n grid rooms initialized with these three possible values. -1 A wall or an obstacle. 0 A gate. INF Infinity means an empty room. We use the value 231 - 1 = 2147483647 to represent INF as you may assume that the distance to a gate is less than 2147483647. Fill each empty room with the distance to its nearest gate. If it is impossible to reach a gate, it should be filled with INF....

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

673. Number of Longest Increasing Subsequence

Given an integer array nums, return the number of longest increasing subsequences. Notice that the sequence has to be strictly increasing. 1 2 3 4 5 6 7 8 9 10 11 Example 1: Input: nums = [1,3,5,4,7] Output: 2 Explanation: The two longest increasing subsequences are [1, 3, 4, 7] and [1, 3, 5, 7]. Example 2: Input: nums = [2,2,2,2,2] Output: 5 Explanation: The length of longest continuous increasing subsequence is 1, and there are 5 subsequences' length is 1, so output 5....

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

126. Word Ladder II

A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> … -> sk such that: Every adjacent pair of words differs by a single letter. Every si for 1 <= i <= k is in wordList. Note that beginWord does not need to be in wordList. sk == endWord Given two words, beginWord and endWord, and a dictionary wordList, return all the shortest transformation sequences from beginWord to endWord, or an empty list if no such sequence exists....

<span title='2021-11-25 00:00:00 +0000 UTC'>November 25, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx