commit
dac9cdc8c6
@ -0,0 +1 @@
|
|||||||
|
.vs/
|
@ -0,0 +1,14 @@
|
|||||||
|
## Getting Started
|
||||||
|
|
||||||
|
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
|
||||||
|
|
||||||
|
## Folder Structure
|
||||||
|
|
||||||
|
The workspace contains two folders by default, where:
|
||||||
|
|
||||||
|
- `src`: the folder to maintain sources
|
||||||
|
- `lib`: the folder to maintain dependencies
|
||||||
|
|
||||||
|
## Dependency Management
|
||||||
|
|
||||||
|
The `JAVA DEPENDENCIES` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-pack/blob/master/release-notes/v0.9.0.md#work-with-jar-files-directly).
|
@ -0,0 +1,67 @@
|
|||||||
|
public class L0085 {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
char[][] g = {{'0','0','0','0','0','0','1'},{'0','0','0','0','1','1','1'},{'1','1','1','1','1','1','1'},{'0','0','0','1','1','1','1'}};
|
||||||
|
System.out.print(maximalRectangle(g));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int maximalRectangle(char[][] matrix) {
|
||||||
|
int x, y;
|
||||||
|
int i,j;
|
||||||
|
int row = matrix.length;
|
||||||
|
int col;
|
||||||
|
if (row == 0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
col = matrix[0].length;
|
||||||
|
}
|
||||||
|
int sum = 0;
|
||||||
|
for (x = 0; x < row; x++) {
|
||||||
|
for (y = 0; y < col; y++) {
|
||||||
|
if (matrix[x][y] == '1') {
|
||||||
|
i = x;
|
||||||
|
j = y;
|
||||||
|
int a = 1;
|
||||||
|
int b = 1;
|
||||||
|
int k;
|
||||||
|
int sum2 = 0;
|
||||||
|
while (i < row) {
|
||||||
|
if (matrix[i][y] == '1') { //竖着往下遍历
|
||||||
|
i++;
|
||||||
|
a = i - x;
|
||||||
|
j = y + 1;
|
||||||
|
int temp = j;
|
||||||
|
while (j < col) {
|
||||||
|
for (k = x; k < i; k++){
|
||||||
|
if (matrix[k][j] == '0'){ //遇到横的为零
|
||||||
|
temp = j;
|
||||||
|
b = temp - y;
|
||||||
|
j = col;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
temp = j + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
b = temp - y;
|
||||||
|
if (a*b > sum2){
|
||||||
|
sum2 = a*b;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sum2 > sum){
|
||||||
|
sum = sum2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sum;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class L0455 {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
int[] g = { 10, 9, 8, 7 };
|
||||||
|
int[] s = { 5, 6, 7, 8, 6 };
|
||||||
|
System.out.print(findContentChildren(g, s));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int findContentChildren(int[] g, int[] s) {
|
||||||
|
int i, j;
|
||||||
|
int g_num = g.length;
|
||||||
|
int s_num = s.length;
|
||||||
|
Arrays.sort(g);
|
||||||
|
Arrays.sort(s);
|
||||||
|
int sum = 0;
|
||||||
|
int a = 0;
|
||||||
|
int position = 0;
|
||||||
|
for (i = 0; i < s_num; i++) {
|
||||||
|
for (j = position; j < g_num; j++) {
|
||||||
|
a += 1;
|
||||||
|
if (s[i] >= g[j]) {
|
||||||
|
// System.out.println(s[i]);
|
||||||
|
// System.out.println(g[j]);
|
||||||
|
sum = sum + 1;
|
||||||
|
position = j + 1;
|
||||||
|
j = g_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// System.out.println(a);
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue