// two loops can be used, one for fetching, another for matching but that is O(n^2). better is to use freq. of each char as ques says it only consists on lowercase chars.