Skip to content

Instantly share code, notes, and snippets.

@abdulrehmank
Created September 19, 2016 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdulrehmank/73a40a137b5600961f60723a95915bde to your computer and use it in GitHub Desktop.
Save abdulrehmank/73a40a137b5600961f60723a95915bde to your computer and use it in GitHub Desktop.
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