@@ -81,6 +81,50 @@ function printFrequency (freqObj) {
8181freqCounter ([ 1 , 2 , 3 , 1 , 3 , 4 , 4 , 4 , 4 , 2 , 5 ]);
8282```
8383
84+ ## Java Implementation
85+
86+ ### [ Solution] ( ./Java/Freq.java )
87+
88+ ``` java
89+ /**
90+ * @date 14/01/19
91+ * @author SPREEHA DUTTA
92+ */
93+ import java.util.* ;
94+ public class Freq {
95+ public static void main (String []args )
96+ {
97+ int n;int i;int t;int k= 0 ;
98+ Scanner sc= new Scanner (System . in);
99+ System . out. println(" Enter number of elements in the array " );
100+ n= sc. nextInt();
101+ int arr[]= new int [n];
102+ System . out. println(" Enter elements of the array " );
103+ for (i= 0 ;i< n;i++ )
104+ arr[i]= sc. nextInt();
105+ Arrays . sort(arr);
106+ if (n!= 1 ){
107+ if (arr[0 ]== arr[1 ])
108+ k= 1 ;
109+ }
110+ else
111+ System . out. println(" frequency of " + arr[0 ]+ " is " + 1 );
112+ for (i= 1 ;i< n;i++ )
113+ {
114+ if (arr[i]== arr[i- 1 ])
115+ k++ ;
116+ else
117+ {
118+ System . out. println(" frequency of " + arr[i- 1 ]+ " is " + k);
119+ k= 1 ;
120+ }
121+ }
122+ if (n!= 1 )
123+ System . out. println(" frequency of " + arr[i- 1 ]+ " is " + k);
124+ }
125+ }
126+ ```
127+
84128### Python Implementation
85129
86130#### [ Solution] ( ./Python/A_Frequency_Counter.py )
@@ -202,6 +246,42 @@ function countUniques (arr) {
202246console .log (` Number of unique elements = ${ countUniques ([1 , 1 , 2 , 2 , 2 , 3 , 4 , 4 , 4 , 4 , 4 , 5 , 5 , 5 , 6 , 7 ])} ` );
203247```
204248
249+ ## Java Implementation
250+
251+ ### [ Solution] ( ./Java/Unique.java )
252+
253+ ``` java
254+ /**
255+ * @date 14/01/19
256+ * @author SPREEHA DUTTA
257+ */
258+ import java.util.* ;
259+ public class Unique {
260+ public static void countUniques (int arr [])
261+ {
262+ int k= 1 ;
263+ for (int i= 1 ;i< arr. length;i++ )
264+ {
265+ if (arr[i]!= arr[i- 1 ])
266+ k++ ;
267+ }
268+ System . out. println(" Number of unique elements = " + k);
269+ }
270+ public static void main (String []args )
271+ {
272+ int n;int i;
273+ Scanner sc= new Scanner (System . in);
274+ System . out. println(" Enter number of elements" );
275+ n= sc. nextInt();
276+ int arr[]= new int [n];
277+ System . out. println(" Enter elements of the array " );
278+ for (i= 0 ;i< n;i++ )
279+ arr[i]= sc. nextInt();
280+ countUniques(arr);
281+ }
282+ }
283+ ```
284+
205285### Python Implementation
206286
207287#### [ Solution] ( ./Python/B_Count_Uniques.py )
@@ -218,6 +298,7 @@ def countUniques(data):
218298data = [1 , 1 , 2 , 2 , 2 , 3 , 4 , 4 , 4 , 4 , 4 , 5 , 5 , 5 , 6 , 7 ]
219299print (" Number of unique elements =" , countUniques(data))
220300```
301+
221302***
222303
223304## Question 3 -- Check Power N
@@ -298,6 +379,47 @@ console.log (checkPowerN ([1, 2, 3, 4], [4, 9, 1, 16], 2));
298379console .log (checkPowerN ([3 , 4 , 5 , 2 ], [1 , 2 , 3 ], 4 ));
299380```
300381
382+ ## Java Implementation
383+
384+ ### [ Solution] ( ./Java/Power.java )
385+
386+ ``` java
387+ /**
388+ * @date 14/01/19
389+ * @author SPREEHA DUTTA
390+ */
391+ import java.util.* ;
392+ public class Power {
393+ public static void main (String []args )
394+ {
395+ Scanner sc= new Scanner (System . in);
396+ int n,p;int i,j;int k= 0 ;
397+ System . out. println(" Enter size of the array " );
398+ n= sc. nextInt();
399+ ArrayList<Integer > arr1 = new ArrayList<Integer > (n);
400+ ArrayList<Integer > arr2 = new ArrayList<Integer > (n);
401+ System . out. println(" Enter elements of the first array " );
402+ for (i= 0 ;i< n;i++ )
403+ arr1. add(sc. nextInt());
404+ System . out. println(" Enter elements of the second array " );
405+ for (i= 0 ;i< n;i++ )
406+ arr2. add(sc. nextInt());
407+ System . out. println(" Enter power" );
408+ p= sc. nextInt();
409+ for (i= 0 ;i< n;i++ )
410+ {
411+ int t= (int )(Math . pow(arr1. get(i),p));
412+ if (arr2. contains(t))
413+ k++ ;
414+ }
415+ if (k== n)
416+ System . out. println(" true" );
417+ else
418+ System . out. println(" false" );
419+ }
420+ }
421+ ```
422+
301423### Python Implementation
302424
303425#### [ Solution] ( ./Python/C_Check_Power_N.py )
0 commit comments