Skip to content

Instantly share code, notes, and snippets.

@Kjaer
Last active April 8, 2019 10:23
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 Kjaer/8f9b169c2f9a9ebcfb42d94810ba88ea to your computer and use it in GitHub Desktop.
Save Kjaer/8f9b169c2f9a9ebcfb42d94810ba88ea to your computer and use it in GitHub Desktop.
find longest same char
/*
Algorithmic task
Given a string of length 1048576,
find the position of the longest substring made from identical characters.
It is guaranteed that there is only one such substring and its length is 8192.
You are not allowed to peek inside the string, however you can call an external
function "getMaxLength(int startPosition, int endPosition)" which will return
the longest number of identical consecutive characters found within the interval.
Describe your solution in code or prose.
*/
const LONGEST = 8192;
function getMaxLength() {}
function getLongest(source_str, start_pos){
let longestInSelectedPart = getMaxLength(source_str, start_pos, (start_pos + LONGEST -1));
if(longestInSelectedPart == LONGEST){
return start_pos;
}
return getLongest(start_pos++);
}
getLongest("stringggg", 0);
/*
Algorithmic task
Missing Integer:
Find the minimal positive integer not occurring in a given sequence.
A = [1,4,3,2,1,2,6] = 5
A = [1,3,2,1] = 4
A = [-1, -3] = 1
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment