and investment firm invest into three different companies shares A B and C. as they invested they created a string of all their investments in order. Given a string of investments determine the number of time. They invested in all three companies shares

An investment firm invested into 3 different companies’ shares: A, B and C. As they invested, they created a string of all of their investments in order. Given a string of investments, determine the number of time periods they invested in all three companies’ shares. For example, given the investments ass = “ABBCZBAC”, for total number of investments n = 7. Starting from the left, the first substring that contains an investment in all companies is ‘ABBC. There are 13 substrings of a which meet the criterion: “ABBC”, “ABBCZ”, “ABBCZB”, “ABBCZBA”, “ABBCZBAC”, “BBCZBA”, “BBCZBAC”, “BCZBA”, “BCZBAC”, “CZBA”, “CZBAC”, “ZBAC”, “BAC”) Note: Two substrings are considered different if the starting, ending, or both positions differ. Function Description Complete the function analyzelnvestments in the editor below. The function must return a long integer analyzeinvestments has the following parameter(s): s: a string of length Constraints • 1sns 105 • sli) cAZ) (where 0 si

**Technifi Expert’s Answer:**

public class Result {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s;
long investCount;
s = sc.next();
investCount = analyzeInvestments(s);
System.out.println(investCount);
}
public static long analyzeInvestments(String s)
{
long count = 0;
for(int i=0; i<=s.length()-3; i++)
{
for(int j=i+3; j<=s.length(); j++)
{
if(s.substring(i, j).contains("A") && s.substring(i, j).contains("B") && s.substring(i, j).contains("C"))
count++;
}
}
return count;
}
}

If you happen to run into some problem while following the steps, please make sure to let us know in the comment section below, we’ll do our best to solve it. Apart from that, you can contact us on Facebook and Twitter, however we can’t guarantee a rapid reaction time over those platform