Thought Works Imp
Thought Works Imp
*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
class Frequency {
public static void main (String[] args) {
/*int [][]arr = { { 9, 9, 6, 10, 4 },
{ 5, 5, 10, 2, 2 },
{ 5, 5, 8, 7, 3 },
{ 2, 6, 6, 1, 6 },
{1, 7, 3, 8, 9}};*/
int [][]arr = {{1,9,1,1},
{1,1,4,1},
{3,4,1,2},
{1,2,7,7}
};
int k=arr.length-1 ;
int l=arr[k].length-1;
list.add(arr[i][j]);
}
}
//System.out.println(Arrays.toString(vector));
int count=0;
int b=0;int H=0;
int j;
int a=-1,d,c=0,p=0,q=0;
int H_max=0;
int counter=1;
while(count<vector.length-1)
{
b=p%(l+1);
if(b==0)
{
a++;
}
//System.out.println("("+a+","+b+")");
//System.out.println(" ");
counter=a+1;
for(int i=count+1;i<vector.length;i++)
{
d=i%(l+1);
if(i%(l+1)==0)
{
counter++;
}
c=counter-1;
//System.out.println("("+c+","+d+")");
//System.out.println(" ");
H=vector[count]+vector[i]-Math.abs(a-c)-Math.abs(b-d);
if(H_max<H)
H_max=H;
}
System.out.println(H_max);
count++;
c=0;
d=0;
p++;
}
}
import java.util.*;
int sum=0;
int friend=0;
int friend_max=0;
list.add(arr[i][j]);
}
}
while(count<vector.length)
{
if(!(temp.contains(vector[count])))
{
temp.add(0);
temp.add(vector[count]);
temp.add(vector[count+1]);
if(vector[count]==vector[i])
{
temp.add(vector[i+1]);
}
}
}
count=count+2;
}
temp.add(0);
System.out.println(temp);
System.out.println(result1);
for(int i=0;i<result1.size();i++)
{
System.out.println(result1.get(i));
result1.toArray();
friend=0;
for(int j=1;j<temp.size();j++)
{
if(temp.get(j)!=0 )
{
sum=sum+A[result1.get(i).indexOf(temp.get(j))];
}
else if(temp.get(j)==0 )
{
friend=friend+((sum*(sum-1))/2);
if(friend_max<friend)
{
friend_max=friend;
}
sum=0;
}
}
}
System.out.println(friend_max );
}