FastPrepFastPrep
Problem Brief

Most Unique Elements (Part 2 :)

OA

  • Most Unique Elements (Part 1 :D
  • Most Unique Elements (Part 2 :O
  • Most Unique Elements (Part 3 :3
  • The 2nd parameter (boolean) is to use Jaccard Similarity instead of most common character. Refactor your code to select the strings that have the lowest average Jaccard Similarity when compared to every other string if this parameter is True. If the parameter is false you should still calculate the lowest proportion in Part 1.

    The rest of your code is the same as Part 1: return a string composed of the characters that are uniquely present in the selected strings across the entire list.

    For this part, assume there’s a function imported that calculates the pair-wise jaccard similarity between two strings (returns a number between 0 and 1):

    1 -> true; 0 -> false

    Function Definition:

    def jaccard(string1, string2):

    return 0

    Make sure the tests for Part 1 still pass.

    Big thanks to the awesome friend who shared the source!

    Hi~ There is no example test case coming with the source, so the example below is just a placeholder. The problem statement and function definition should give us a clear idea of what this problem is asking~

    1Example 1

    Input
    group = ["aba", "ab", "abbcdd"]
    Output
    "cdd"
    Explanation
    PLACEHOLDER ONLY~~~ - "aba": most common character is 'a', with proportion 2/3 - "ab": most common characters are 'a' and 'b', with proportion 1/2 - "abbcdd": most common character are 'b' and 'd', with proportion 2/6 The smallest proportion is 2/6, so we select the last string "abbcdd" and return the characters that are only present in this string: "cdd"
    public int jaccard(String string1, String string2) {
      // write your code here
    }
    
    Input

    group

    ["aba", "ab", "abbcdd"]

    Output

    "cdd"

    Sign in to submit your solution.