JS solution based on this great idea

var longestSubstring = function(s, k) { let chars = new Set(s); for (const c of chars) { let splitRes = s.split(c); if (splitRes.length - 1 < k) { return splitRes.reduce((max, sub) => { return Math.max(max, longestSubstring(sub, k)); }, 0); } } return s.length; };Longest Substring with At Least K Repeating Characters