Uva 10252.common permutation

Nov 18, 2009

Problem: 10252.common permutation

!Be careful: here may be empty lines in the input.
Discussion:
You can use straightforward algorithm or the following:
1. First take two array A[],B[],sort two input by using qsort() function.
2. Each char of two string is convert into integer n then A[n]++ for A[] and B[n]++ for B[].
3. Then from i=97 to 122 --> a to z element of A[] & B[] check, if both have value greater than 0 then take m=min(A[i],B[i]). Convert I to char ch. Ch print m times
4. Print newline.




Code In C/C++:



Another Code In C/C++:

No comments:

Post a Comment