Finding common characters in two strings

前端 未结 13 2573
终归单人心
终归单人心 2020-12-15 14:09

I am coding for the problem in which we got to count the number of common characters in two strings. Main part of the count goes like this

for(i=0; i < st         


        
13条回答
  •  一整个雨季
    2020-12-15 14:46

    This is very simple. Take two int arrays freq1 and freq2. Initialize all its elements to 0. Then read your strings and store the frequencies of the characters to these arrays. After that compare the arrays freq1 and freq2 to find the common characters.

提交回复
热议问题