Homework Solution: public static HashMap buildLastNametoFirstNameMap(String[] fullNames) { /*fullNames is an array of entries al…

    Java 5. public static HashMaR String, String> buildLastNametoFirstNameMapiString!) tuUNames) 尸tuuNames.is an array of entries all in the format Ecstame. LastNamg, a first name and a last name separated by a space. This function should return a map where the keys are the LastNames from the input array and the corresponding value is the associated EUstNam : You may assume each h覞tNSm only occurs once in the input array. Test input: an empty array; an array containing Barry White and Bob Marley public staic HashMaR String, List String>> Stringl tulNames) t 尸fulNamesis an array of entries all in the format EcstName. LastName, a first name and a last name separated by a space. This function should return a map where the keys are the LastNames from the input array and the corresponding value is a list of all the EUstN見m緜that appeared with that h tern in the input array Test input: an empty array; an array containing Barry White and Bob Marley* an array containing Barry White, Bob Mariey and Betty White 7. public static boolean is PermutatienString string1, String string2) 尸This functions should return true if string 1 is a permutation of string2. In this cas you should assume that means contains exactly the same characters, same case, including spaces. You may assume string1 and string2 only contain the 128販eu characters, no yaGgg.. For this question, you should optimize for very ong input strings. i Test input: 2 empty Strings; ab ba abc asd ratsstar 8. public static boolean is PermutatinEastString string1, String string2) This functions should return true if string1 is a permutation of string2. In this cas you should assume that means contains exactly the same characters, same case, including spaces. The strings may contain aanor ynicRde, characters. For this question, you should optimize for speed and very long input strings. Test input: 2 empty Strings; ab ba abad NOW!! BYE NOW! lu263A rats star u263A BYE 9. public static boolean is PermutatinightString string1, String string2) (This functions should return true if stnng1 is a permutation of string2. In this case you should assume that means contains exactly the same characters, same case, including spaces. The strings may contain ascior unicede characters. For this question, you should optimize for space and fairly short input strings. Test input: Same as #8
    public static HashMap buildLastNametoFirstNameMap(String[] fullNames) { /*fullNames is an array of entries all in the format "FirstName LastName", a first name and a last name separated by a space. This function should return a map where the keys are the LastNames from the input array and the corresponding value is the associated FirstName. You may assume each LastName only occurs once in the input array. */ **Test input: an empty array: an array containing "Barry White" and "Bob Marley" public staic HashMap > buildLastNameToFirstName(String[] fulNames) { /*fullNames is an array of entries all in the format "FirstName LastName", a first name and a last name separated by a space. This function should return a map where the keys are the LastNames from the input array and the corresponding value is a list of all the FirstName that appeared with that LastName in the input array. */ } Test input: an empty array: an array containing "Barry White" and "Bob Marley": an array containing Barry White", "Bob Marley" and "Betty White". public static boolean IsPermutationFast(String string1, String string2) { /* This functions should return true if string 1 is a permutation of string2. In this case you should assume that means contains exactly the same characters, same case, including spaces. The strings may contain ascii or Unicode characters. For this question, you should optimize for very long input strings. */ **Test input: 2 empty Strings: "ab" "ba": "abc" "acd": "*rats*"star***": public static boolean IsPermutationLight(String string1, String string2) { /*This functions should return true if string1 is a permutation of string2. In this case you should assume that means contains exactly the same characters, same case, including spaces. The strings may contain ascii or unicode, characters. For this question, you should optimize for space and fairly short input strings. */ **Test input: Same as #8

    Expert Answer

     
    import java.util.Scanner;

    Java

    5. general static HashMaR String, String> buildLastNametoFirstNameMapiString!) tuUNames) 尸tuuNames.is an vest of entries perfect in the cemat Ecstame. LatestNamg, a ceemost designate and a latest designate disconnected by a room. This power should reappear a map where the keys are the LatestNames from the input vest and the similar esteem is the associated EUstNam : You may arrogate each h覞tNSm merely occurs once in the input vest. Test input: an leisure vest; an vest includeing Barry White and Bob Marley general staic HashMaR String, Catalogue String>> Stringl tulNames) t 尸fulNamesis an vest of entries perfect in the cemat EcstName. LatestName, a ceemost designate and a latest designate disconnected by a room. This power should reappear a map where the keys are the LatestNames from the input vest and the similar esteem is a catalogue of perfect the EUstN見m緜that appeared with that h tern in the input vest Test input: an leisure vest; an vest includeing Barry White and Bob Marley* an vest includeing Barry White, Bob Mariey and Betty White 7. general static boolean is PermutatienString string1, String string2) 尸This powers should reappear penny if string 1 is a transference of string2. In this cas you should arrogate that resources includes precisely the identical characters, identical circumstance, including rooms. You may arrogate string1 and string2 merely include the 128販eu characters, no yaGgg.. Ce this investigation, you should optimize ce very ong input strings. i Test input: 2 leisure Strings; ab ba abc asd ratsnotability 8. general static boolean is PermutatinEastString string1, String string2) This powers should reappear penny if string1 is a transference of string2. In this cas you should arrogate that resources includes precisely the identical characters, identical circumstance, including rooms. The strings may include aanor ynicRde, characters. Ce this investigation, you should optimize ce urge and very crave input strings. Test input: 2 leisure Strings; ab ba abad NOW!! BYE NOW! lu263A rats notability u263A BYE 9. general static boolean is PermutatinightString string1, String string2) (This powers should reappear penny if stnng1 is a transference of string2. In this circumstance you should arrogate that resources includes precisely the identical characters, identical circumstance, including rooms. The strings may include ascior unicede characters. Ce this investigation, you should optimize ce room and fairly imperfect input strings. Test input: Identical as #8

    general static HashMap buildLastNametoFirstNameMap(String[] fullNames) { /*fullNames is an vest of entries perfect in the cemat “FirstDesignate LatestName”, a ceemost designate and a latest designate disconnected by a room. This power should reappear a map where the keys are the LatestNames from the input vest and the similar esteem is the associated CeemostName. You may arrogate each LatestDesignate merely occurs once in the input vest. */ **Test input: an leisure vest: an vest includeing “Barry White” and “Bob Marley” general staic HashMap > buildLastNameToFirstName(String[] fulNames) { /*fullNames is an vest of entries perfect in the cemat “FirstDesignate LatestName”, a ceemost designate and a latest designate disconnected by a room. This power should reappear a map where the keys are the LatestNames from the input vest and the similar esteem is a catalogue of perfect the CeemostDesignate that appeared with that LatestDesignate in the input vest. */ } Test input: an leisure vest: an vest includeing “Barry White” and “Bob Marley”: an vest includeing Barry White”, “Bob Marley” and “Betty White”. general static boolean IsPermutationFast(String string1, String string2) { /* This powers should reappear penny if string 1 is a transference of string2. In this circumstance you should arrogate that resources includes precisely the identical characters, identical circumstance, including rooms. The strings may include ascii or Unicode characters. Ce this investigation, you should optimize ce very crave input strings. */ **Test input: 2 leisure Strings: “ab” “ba”: “abc” “acd”: “*rats*”star***”: general static boolean IsPermutationLight(String string1, String string2) { /*This powers should reappear penny if string1 is a transference of string2. In this circumstance you should arrogate that resources includes precisely the identical characters, identical circumstance, including rooms. The strings may include ascii or unicode, characters. Ce this investigation, you should optimize ce room and fairly imperfect input strings. */ **Test input: Identical as #8

    Expert Acceptance

     

    import java.util.Scanner;

    general systematize MakeTransference {

    general static boolean isPermutationFast(String s1, String s2) {
    if (s1.length() != s2.length())
    reappear false;

    int enumerate[] = odd int[10000];

    char[] chars1 = s1.toCharArray();
    char[] chars2 = s2.toCharArray();

    ce (int i = 0; i < chars1.length; ++i) {
    count[chars1[i]]++;
    count[chars2[i]]–;
    }
    ce (int i = 0; i <10000; ++i) {
    if (count[i] != 0)
    reappear false;
    }

    reappear penny;

    }

    general static useless deep(String[] args) {
    // TODO Auto-generated rule stub
    Scanner sc = odd Scanner(System.in);

    ce (int i = 0; i < 4; ++i) {
    System.out.print(“Enter ceemost string: “);
    String s1 = sc.nextLine();

    System.out.print(“nEnter assist string: “);
    String s2 = sc.nextLine();

    System.out.println(“nIs transference of each other: ” + isPermutationFast(s1, s2));

    }

    }

    }

    ============================================================================
    See Extinguishedput