摘要:
题目如下: Every email consists of a local name and a domain name, separated by the @ sign. For example, in alice@leetcode.com, alice is the local name, an 阅读全文
摘要:
题目如下: Given an integer array A, and an integer target, return the number of tuples i, j, k such that i < j < k and A[i] + A[j] + A[k] == target. As th 阅读全文
摘要:
题目如下: Given an array A of 0s and 1s, divide the array into 3 non-empty parts such that all of these parts represent the same binary value. If it is po 阅读全文
摘要:
题目如下: A string of '0's and '1's is monotone increasing if it consists of some number of '0's (possibly 0), followed by some number of '1's (also possi 阅读全文
摘要:
题目如下: Your friend is typing his name into a keyboard. Sometimes, when typing a character c, the key might get long pressed, and the character will be 阅读全文
摘要:
题目如下: In a network of nodes, each node i is directly connected to another node j if and only if graph[i][j] = 1. Some nodes initial are initially infe 阅读全文
摘要:
题目如下: 解题思路:抛开移动的过程只看移动完成的结果,记图片左上角为顶点,正方形边长为board,要使得两个图片要有重叠,那么一定其中一张图片的顶点和另外一张图片的某一个点重合。假设图片A的顶点A(0,0)和图片B的其中一个点B(x,y)重合,那么A与B重合的区域就是A(0,0) -> A(boa 阅读全文
摘要:
题目如下: 解题思路:非常简单的题目,引入两个变量oddInx = 1和evenInx = 0,和与A等长的结果数组res。然后遍历A,如果A[i]为偶数,则令res[evenInx] = A[i],evenInx += 2;否则令res[oddInx] = A[i],evenInx += 2。 代 阅读全文
摘要:
题目如下: 解题思路:上周都在忙着参加CTF,没时间做题,今天来更新一下博客吧。括号问题在leetcode中出现了很多,本题的解题思路和以前的括号问题一样,使用栈。遍历Input,如果是'('直接入栈;如果是')'则判断栈顶是否为'(',如果栈顶是'(',栈顶元素出栈,否则要加括号的count加1。 阅读全文
摘要:
题目如下: 解题思路:题目要求的是在数组中找到一个下标最小的index,使得index左边(包括自己)子序列的最大值小于或者等于右边序列的最小值。那么我们可以先把数组从最左边开始到数组最右边所有子序列的最大值都求出来存入leftMax数组,同时也把从数组最右边开始到最左边的所有子序列的最小值求出来存 阅读全文