Digital Sequence

3.8

44 votes
1-D Array, Arrays, Data Structures, Easy, easy
Problem
Description

You are given an array A of length N. You need to find maximum length of subsequence of A which contains any one digit common in all the elements of that subsequence. You are not allowed to count leading zeroes.

Input Format:

First line of input contains N, denoting number of elements.
Second line of input contains N space separated integers, denoting array elements.

Output Format:

Single integer representing maximum length of subsequence containing one digit common.

Input Constraints:

1N105

1Ai109

Sample Input
5
12 11 3 4 5
Sample Output
2
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Maximum length subsequence with one digit common is [ 12 11 ].

Editor Image

?