Skip to content

Commit

Permalink
solution
Browse files Browse the repository at this point in the history
  • Loading branch information
sabira-khan committed Apr 29, 2022
1 parent 10ddbf8 commit 35a3290
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions JavaSolutions/src/com/gitproject/Beecrowd1211_uri.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.gitproject;

import java.io.EOFException;
import java.util.Arrays;
import java.util.Scanner;


public class Beecrowd1211_uri {
public static void main(String[] args) throws EOFException {
Scanner s = new Scanner(System.in);

while (s.hasNextInt()) {

int t = s.nextInt();
s.nextLine();

String[] ff = new String[t];

for (int i = 0; i < t; i++) {
ff[i] = s.nextLine();
}

Arrays.sort(ff);
int e = 0;

for (int i = 0; i < t-1; i++) {
for (int j = 0; j < ff[i].length(); j++) {
if (ff[i].charAt(j) == ff[i+1].charAt(j)) {
e++;
}
else
break;
}
}
System.out.println(e);
}
}
}

0 comments on commit 35a3290

Please sign in to comment.