日常: 算法、数据结构、分布式系统、日常思考感悟等

[LeetCode] Pacific Atlantic Water Flow

You are given an m x n integer matrix heights representing the height of each unit cell in a continent. The Pacific ocean touches the continent’s left and top edges, and the Atlantic ocean touches the continent’s right and bottom edges. Water can only flow in four directions up, down, left, and right. Water flows from a cell to an adjacent one with an equal or lower height. Return a list of grid coordinates where water can flow to both the Pacific and Atlantic oceans.......

[LeetCode] Palindromic Substrings

Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters.......

[LeetCode] Longest Valid Parentheses

Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.......

[LeetCode] Minimum Operations to Make Array Equal

You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e. 0 <= i < n). Given an integer n, the length of the array. Return the minimum number of operations needed to make all the elements of arr equal.......

[LeetCode] Global And Local Inversions

We have some permutation A of [0, 1, …, N - 1], where N is the length of A. The number of (global) inversions is the number of i < j with 0 <= i < j < N and A[i] > A[j]. The number of local inversions is the number of i with 0 <= i < N and A[i] > A[i+1]. Return true if and only if the number of global inversions is equal to the number of local inversions.......

[LeetCode] Design Circular Queue

Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle. It is also called “Ring Buffer”.......