Created
September 19, 2016 14:00
-
-
Save abdulrehmank/73a40a137b5600961f60723a95915bde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(S) { | |
// write your code in JavaScript (Node.js 6.4.0) | |
console.log(S); | |
var longest_string_length = -1; | |
for(var j = 0; j < S.length; j++) { | |
var len = S.length; | |
for(k = len; k > j; k--) { | |
var str = S.substring(j, k), | |
patt = /([A-Z]*[a-z]*[A-Z]+[a-z]*)+/g, | |
match = patt.exec(str); | |
if(match && match.length > 0) { | |
match = match[0]; | |
if(match.length > longest_string_length) { | |
longest_string_length = match.length; | |
} | |
} | |
} | |
} | |
return longest_string_length; | |
} | |
console.log(solution('asdfDF3GH34aDFG1HJsdf')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment