云栖社区Java、Redis、MongoDB运营小编,有意合作请联系钉钉:15810436147
There is an m by n grid with a ball. Given the start coordinate (i,j) of the ball, you can move the ball to adjacent cell or cross the grid boundary in four directions (up, down, left, right).
A zero-indexed array A consisting of N different integers is given. The array contains all integers in the range [0, N - 1].
Design an in-memory file system to simulate the following functions: ls: Given a path in string format.
Given a string representing an expression of fraction addition and subtraction, you need to return the calculation result in string format.
Given a positive integer n, find the number of non-negative integers less than or equal to n, whose binary representations do NOT contain consecutive ones.
Given an m * n matrix M initialized with all 0's and several update operations. Operations are represented by a 2D array, and each operation is repr.
Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings.
Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die.
这篇小结主要是参考这篇帖子从头到尾彻底理解KMP,不得不佩服原作者,写的真是太详尽了,让博主产生了一种读学术论文的错觉。后来发现原作者是写书的,不由得更加敬佩了。博主不才,尝试着简化一些原帖子的内容,希望能更通俗易懂一些。
You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way.
Given a list of directory info including directory path, and all the files with contents in this directory, you need to find out all the groups of d.
Given a string representing a code snippet, you need to implement a tag validator to parse the code and return whether it is valid.
Design and implement a data structure for a compressed string iterator. It should support the following operations: next and hasNext.
Given a string s and a list of strings dict, you need to add a closed pair of bold tag <b> and </b> to wrap the substrings in s that exist in dict.
Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.
Given the root of a binary tree, then value v and depth d, you need to add a row of nodes with value v at the given depth d.
Given m arrays, and each array is sorted in ascending order. Now you can pick up two integers from two different arrays (each array picks one) and calculate the distance.
Given a positive integer a, find the smallest positive integer b whose multiplication of each digit equals to a.
Given an integer array, find three numbers whose product is maximum and output the maximum product.
Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks.
Given two integers n and k, find how many different arrays consist of numbers from 1 to n such that there are exactly k inverse pairs.
There are n different online courses numbered from 1 to n. Each course has some duration(course length) tand closed on dth day.
Given n processes, each process has a unique PID (process id) and its PPID (parent process id). Each process only has one parent process, but may have one or more children processes.
Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where in each step you can delete one character in either string.
Your task is to design the basic function of Excel and implement the function of sum formula. Specifically, you need to implement the following func.
Given a non-negative integer c, your task is to decide whether there're two integers a and b such that a2 + b2 = c. Example 1: Input: 5 Output: True Explanation: 1 * 1 + 2 * 2 = 5 Example 2: Input: 3 Output: False 这道题让我们求一个数是否能由平方数之和组成,刚开始博主没仔细看题,没有看到必须要是两个平方数之和,博主以为任意一个就可以。
You have k lists of sorted integers in ascending order. Find the smallest range that includes at least one number from each of the k lists.
In combinatorial mathematics, a derangement is a permutation of the elements of a set, such that no element appears in its original position.
You are given several logs that each log contains a unique id and timestamp. Timestamp is a string that has the following format: Year:Month:Day:Hour:Minute:Second, for example, 2017:01:01:23:59:59.
Given the running logs of n functions that are executed in a nonpreemptive single threaded CPU, find the exclusive time of these functions.
Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array.