//暴力法 时间复杂度 O(m * n) //根据排序的规律观察,得到类似2叉搜索树的解法 O(m + n) class Solution { public boolean findNumberIn2DArray(int[][] matrix, int target) { //判空 if(matri ...
分类:
编程语言 时间:
2020-12-17 12:41:42
阅读次数:
1
Description: Given a (singly) linked list with head node root, write a function to split the linked list into k consecutive linked list "parts". The l ...
分类:
其他好文 时间:
2020-12-14 13:00:34
阅读次数:
3
Description A frightful matrix is a square matrix of order n where the first row and the first column are explicitly specified, while the other elemen ...
分类:
其他好文 时间:
2020-12-11 11:54:24
阅读次数:
4
初一看,sb题,上去一个并查集,很快啊,返回一个MLE,定睛一看,系统开的内存很小,但是这个算法复杂度又是这么正确 因此考虑优化内存,这样用滚动数组优化即可 #include<bits/stdc++.h> using namespace std; typedef long long ll; type ...
分类:
其他好文 时间:
2020-12-10 11:39:56
阅读次数:
13
Difficulty: Medium Related Topics: Array, Backtracking Link: https://leetcode.com/problems/word-search/ Description Given an m x n board and a word, f ...
分类:
其他好文 时间:
2020-12-10 11:30:28
阅读次数:
11
Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and ...
分类:
编程语言 时间:
2020-12-10 11:13:48
阅读次数:
6
Description: Given a singly linked list, determine if it is a palindrome. Link: https://leetcode.com/problems/palindrome-linked-list/ Examples: Exampl ...
分类:
其他好文 时间:
2020-12-05 11:02:42
阅读次数:
7
package LeetCode_771 /** * 771. Jewels and Stones * https://leetcode.com/problems/jewels-and-stones/ * You're given strings J representing the types o ...
分类:
其他好文 时间:
2020-12-05 10:48:43
阅读次数:
7
###题目 1389. Create Target Array in the Given Order ###解题方法 创建一个新数组rat,将nums中的数按照index的位置插入rat即可。 时间复杂度:O(n*n) 空间复杂度:O(n) ###代码 class Solution: def cre ...
分类:
其他好文 时间:
2020-12-04 11:06:02
阅读次数:
6
题目 74. 搜索二维矩阵 思路1(暴力) 遍历二维数组的所有的元素,看看是否存在target 代码 class Solution { public boolean searchMatrix(int[][] matrix, int target) { for (int i = 0; i < matr ...
分类:
其他好文 时间:
2020-12-03 11:50:12
阅读次数:
4