Split Strings - Company-specific OAs / Google OA

https://algo.monster/problems/google_oa_split_strings

Javascript solution

function totalWaysToSplitStrings(s) {
if(s.length === 0) return 1;
let count = 0
for (let index = 1; index < s.length; index++) {
let s_1 = new Set(s.slice(0,index));
let s_2 = new Set(s.slice(index,s.length));
count += s_1.size === s_2.size ? 1 : 0;
}
return count;
}

Python code (can use memoization for better performance):

from collections import Counter

def total_ways_to_split_strings(s: str) -> int:
    # WRITE YOUR BRILLIANT CODE HERE
    if not s:
        return 1
    
    splits = 0
    for i in range(len(s)):
        if len(Counter(s[:i+1])) == len(Counter(s[i+1:])):
            splits += 1        
    return splits