natdev
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
using System;
public class Program
{
public static void Main()
{
//{0,2,1,2,2,1,0}
int[] ar= {1,3,2,4,5,4,2};
int[] r = lessOrEqual(ar);
for (int i = 0; i < r.Length; i++)
Console.WriteLine(r[i]);
}
public static int[] lessOrEqual(int[] arr)
{
int[] r1 = new int[arr.Length];
for(int i = 0; i < arr.Length; i++)
{
int nf = 0;
for(int j= i+1; j < arr.Length ; j++)
{
if (arr[i] >= arr[j])
nf ++;
}
r1[i] = nf;
}
return r1 ;
}
}
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
- natdev October 31, 2015