Before we make our hiring decision, we have one final question for you to answer.
Write a function that takes two strings X and Y and returns the length of the longest common substring.
You should know how to do this user.
Before we make our hiring decision, we have one final question for you to answer.
Write a function that takes two strings X and Y and returns the length of the longest common substring.
You should know how to do this user.
Other urls found in this thread:
en.wikipedia.org
twitter.com
What's a substring?
>writes it out perfectly in under 30 seconds
"Thanks, but we went with a different candidate, for diversity reasons"
>delusional incel quickly writes shit that doesn't work and insists it's perfect
>doesn't get hired
>must be the niggers
max_sub=0;
for i = 1 : length(X)
for j = (max_sub+i) : length(X)
if has_substr(Y,X(i:j))
max_sub = j-i+1;
end
end
end
return max_sub;
>delusional OP wants help for homework assignment
>writes thread thats very obvious
>calls poster an incel out of nowhere
Jokes on you, I don't even program anymore
>I have youtube channel. Want see it? Why you not want see it? Ok, I hired. I show you later. You watch later. ok?
>>>/tumblr/
kek
i tried, and i failed. What am i doing wrong?
>inb4 using javascript
function commonSubstring(x /*hello*/, y /*ohelloman*/) {
var throwaway;
var collector = [];
var xLetters = [];
var yLetters = [];
var incremneter = 1;
xLetters = x.split('');
yLetters = y.split('');
for (var i = 0; i < xLetters.length; i++) {
for (var j = 0; j < yLetters.length; j++) {
if (xLetters[i] = yLetters[j]) { // om i=0('h'), j=1(h)
while (xLetters[i + incremneter] = yLetters[j + incremneter]) {
throwaway += xLetters[i + incremneter];
++incremneter;
}
collector.push(throwaway);
}
}
}
var longestCommonSubstring = '';
for (var i = 0; i > collector.length; i++) {
if (collector[i].length > longestCommonSubstring.length) {
longestCommonSubstring = arr[i].length;
}
}
console.log(longestCommonSubstring);
return longestCommonSubstring;
}
>javascr-
oh you already found your problem
dear computer wizard, please put a spell on my code and make it work.
This is actually a good task. Sadly it's wery late and I am too lazy.
Oh, that's a good one, sounds just like traveling salesman one.
Before we make our hiring decision, we have one final question for you to answer.
>Enters whiteboard
public class MaxSubString {
public String finMaxSubstring(String a, String b) {
String result = "";
if ((a == null) || (b == null)) {
return result;
}
if (a.equals(b)) {
return a;
}
int start = 0;
int end = start + 1;
while (start
int maxSubstr(std::string X, std::string Y)
{
int a = 0;
int ret = 0;
int tmp = 0;
while(a < X.size()){
int i = a;
int j = 0;
while(i < X.size() && j < Y.size()){
if(X[i] == Y[j]){
tmp++;
i++;
j++;
}else if(tmp){
i = a;
tmp = 0;
}else{
j++;
}
ret = (tmp < ret) ? (ret) : (tmp);
}
a++;
tmp = 0;
}
return ret;
}
I don't know what I'm doing.
Did we get the same homework in data structures class? brilliant thread though.
What's a common substring? Letters that the both two strings have?
Everyone gets this homework, nerd,
(Brainlet wojak):
Array1 = explode(string1, " ");
Longestsubstr = "";
Array2 = explode(string2, " ");
Foreach array1 as substring1
Foreach array2 as substring2
If substring1 == substring2
Longestsubstr == strlen(substring1) > strlen(Longestsubstr) ? Substring1 : longestsubstr;
Return longestsubstr;
a string that occurs withing a larger string.
"ox jumped over" is a substring of "The quick brown fox jumps over the lazy dog"
"he quik brown fo juped" is not a substring, even though all the letters occur in the original string.
function lcs(x, y) {
const m = x.length, n = y.length;
var a = new Array(m+1);
for (i = 0; i len) {
len = a[i][j];
pos = i;
}
} else
a[i][j] = 0;
}
}
return x.slice(pos - len, pos);
}
>insert javascript meme here
static int LongestCommonSubstring(string x, string y)
{
int longest = 0;
for (int i = 0; i < x.Length; i++)
{
for (int len = 1; len + i longest)
{
longest = len;
}
}
}
return longest;
}
public int longestStringLength(int string1, string2){
return string1.length() > string2.length() ? string1 : string2;
}
noobs
Why are you anons doing his homework?
This would actually be a good interview question desu. Separate the folks who know what they're doing from the "coding bootcamp" faggots
i tried my grubby python hands at it.
sorry about the variable names.