Check if given string can be split into four distinct strings | Return true if both strings are equal ; Return if the given string can be split or not . ; Brute Force ; Making 4 string from the given string ; Checking if they are distinct or not . ; Driver code
function strcheck ( s1 , s2 ) { if ( s1 . localeCompare ( s2 ) != 0 ) return false ; return true ; } function check ( s ) { if ( s . length >= 10 ) return true ; for ( let i = 1 ; i < s . length ; i ++ ) { for ( let j = i + 1 ; j < s . length ; j ++ ) { for ( let k = j + 1 ; k < s . length ; k ++ ) { let s1 = " " , s2 = " " , s3 = " " , s4 = " " ; s1 = s . substring ( 0 , i ) ; s2 = s . substring ( i , i + j - i ) ; s3 = s . substring ( j , j + k - j ) ; s4 = s . substring ( k , k + s . length - k ) ; if ( strcheck ( s1 , s2 ) && strcheck ( s1 , s3 ) && strcheck ( s1 , s4 ) && strcheck ( s2 , s3 ) && strcheck ( s2 , s4 ) && strcheck ( s3 , s4 ) ) return true ; } } } return false ; } let str = " " ; if ( check ( str ) ) document . write ( " " ) ; else document . write ( " " ) ;