You are given an N × N matrix in which every cell is colored black or white. Columns are numbered from 0 to N-1 (from left to right). This coloring is represented by a non-empty array of integers A. If the K-th number in the array is equal to X then the X lowest cells in the K-th column of the matrix are black. The rest of the cells in the K-th column are white. The task is to calculate the side length of the biggest black square (a square containing only black cells).
Write a function:
class Solution { public int solution(int[] A); }
that, given an array of integers A of length N representing the coloring of the matrix, returns the side length of the biggest black square.
Examples:
1. Given A = [1, 2, 5, 3, 1, 3], the function should return 2. For example, the black square of side 2 contains the two lowest rows of the 1st and 2nd columns (counting from 0).
2. Given A = [3, 3, 3, 5, 4], the function should return 3. For example, the biggest black square has side 3 and contains the three lowest rows of the last three columns.
3. Given A = [6, 5, 5, 6, 2, 2], the function should return 4. The biggest black square has side 4 and contains the four lowest rows of the first four columns.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [1..100,000];
- each element of array A is an integer within the range [1..N].
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i];
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i];
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i];
if(A[i])
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i];
if(A[i]+)
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i];
if(A[i]+i>=A.Length){
end=A.Length-1;
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+i;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int i=start;i<A[i];i++){
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int i=start;i<A[i];i++){
for(int j=i;j<)
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int i=start;i<A[i];i++){
for(int j=i;j<A[i]+j)
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int i=start;i<A[i];i++){
for(int j=i;j<A[i]+i;j++){
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int i=start;i<A[i];i++){
for(int j=i;j<A[i]+i;j++){
if
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int i=start;i<A[i];i++){
for(int j=i;j<A[i]+i;j++){
if(i+j>=A.Length)
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int i=start;i<A[i];i++){
for(int j=i;j<A[i]+i;j++){
if(i+j>=A.Length){
break;
}
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int i=start;i<A[i];i++){
for(int j=i;j<A[i]+i;j++){
if(i+j>=A.Length){
break;
}
if()
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int i=start;i<A[i];i++){
for(int j=i;j<A[i]+i;j++){
if(i+j>=A.Length){
break;
}
if(A[i]-A[j])
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int i=start;i<A[i];i++){
for(int j=i;j<A[i]+i;j++){
if(i+j>=A.Length){
break;
}
if(A[i]-A[j]<0){
break;
}
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int i=start;i<A[i];i++){
for(int j=i;j<A[i]+i;j++){
if(i+j>=A.Length){
break;
}
if(A[i]A[j]<0){
break;
}
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int i=start;i<A[i];i++){
for(int j=i;j<A[i]+i;j++){
if(i+j>=A.Length){
break;
}
if(A[j]-A[i]<0){
break;
}
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int =start;i<A[i];i++){
for(int j=i;j<A[i]+i;j++){
if(i+j>=A.Length){
break;
}
if(A[j]-A[i]<0){
break;
}
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int j=i;j<A[i]+i;j++){
if(i+j>=A.Length){
break;
}
if(A[j]-A[i]<0){
break;
}
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(i+j>=A.Length){
break;
}
if(A[j]-A[i]<0){
break;
}
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[j]<0){
break;
}
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i])
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}
}
}
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
for(int i=0;i<A.Length;i++){
for(intj=0;j<i;)
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
for(int i=0;i<A.Length;i++){
for(intj=0;j<i;j++){
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
for(int i=0;i<A.Length;i++){
for(intj=0;j<;j++){
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
for(int i=0;i<A.Length;i++){
for(intj=0;j<A.Length;j++){
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
for(int i=0;i<A.Length;i++){
for(intj=0;j<A.Length;j++){
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
for(int i=0;i<A.Length;i++){
for(intj=0;j<A.Length;j++){
for(int k=0;k<i;k++){
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
for(int i=0;i<A.Length;i++){
for(intj=0;j<A.Length;j++){
for(int k=j;k<i;k++){
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
for(int i=0;i<A.Length;i++){
for(intj=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
int c=0;
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
if(A[k]-i)
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
int c=0;
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
if(A[k]-i>=0){
++c;
}
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
int c=0;
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
if(A[k]-i>=0){
++c;
}
}
if(c==i)
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
int c=0;
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
if(A[k]-i>=0){
++c;
}
}
if(c==i){
if(i>max){
max=i;
}
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
int c=0;
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
i
if(A[k]-i>=0){
++c;
}
}
if(c==i){
if(i>max){
max=i;
}
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
int c=0;
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
if(k<A.Length){
}
if(A[k]-i>=0){
++c;
}
}
if(c==i){
if(i>max){
max=i;
}
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
int c=0;
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
if(k<A.Length){
if(A[k]-i>=0){
++c;
}
}
}
if(c==i){
if(i>max){
max=i;
}
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
int c=0;
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
if(k<A.Length){
if(A[k]-i>=0){
++c;
}
}
}
if(c==i){
if(i>max){
max=i;
}
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
int c=0;
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
if(k<A.Length){
if(A[k]-i>=0){
++c;
}
}
}
if(c==i){
if(i>max){
max=i;
}
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
int c=0;
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
if(k<A.Length){
if(A[k]-i>=0){
++c;
}
}
}
if(c==i){
if(i>max){
max=i;
}
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
int c=0;
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
if(k<A.Length){
if(A[k]-i>=0){
++c;
}
}
}
if(c==i){
if(i>max){
max=i;
}
}e
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
int c=0;
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
if(k<A.Length){
if(A[k]-i>=0){
++c;
}
}
}
if(c==i){
if(i>max){
max=i;
}
}else{
c=0;
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
int c=0;
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
if(k<A.Length){
if(A[k]-i>=0){
++c;
}
}
}
if(c==i){
if(i>max){
max=i;
}
}else{
c=0;
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
int c=0;
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
if(k<A.Length){
if(A[k]-i>=0){
++c;
}
}
}
if(c==i){
if(i>max){
max=i;
}
}else{
c=0;
}
}
}
return max;
}
}
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
int count=0;
int max=0;
for(int i=0;i<A.Length;i++){
int start=i-A[i]+1;
if(start<0){
start=0;
}
int end=A[i]+start;
if(A[i]+i>=A.Length){
end=A.Length-1;
}
for(int j=start;j<A[i];j++){
for(int k=j;k<A[j]+j;k++){
if(j+k>=A.Length){
break;
}
if(A[k]-A[i]<0){
break;
}else{
count++;
}
}
if(count==A[i]){
if(count>max){
max=count;
}
}else{
count=0;
}
}
}
int c=0;
for(int i=0;i<A.Length;i++){
for(int j=0;j<A.Length;j++){
for(int k=j;k<i+j;k++){
if(k<A.Length){
if(A[k]-i>=0){
++c;
}
}
}
if(c==i){
if(i>max){
max=i;
}
}else{
c=0;
}
}
}
return max;
}
}
The following issues have been detected: timeout errors.
Tests with the biggest square surrounded by shorter columns. N <= 10.
Tests with alternating small and big numbers (relatively). N <= 15.
Two monotonic sequences or one monotonic and one constant. N <= 75.
Tests with local maximums and local minimums. N <= 75.
Various combinations of monotonic and constant sequences. N <= 750.
running time: 0.492 sec., time limit: 0.100 sec.
Randomly generated tests. N <= 10,000. Score x 2.
Killed. Hard limit reached: 6.000 sec.