Jow Forums Interview

Hello user,

For the 7th round, we're going to let our Software Engineering Manager, DeShawn Williams, take you into the whiteboard room for another short interview.


Given a string, find the length of the longest palindromic substring in it.

Example:

Input: "abbaab"
Output: 4


You should be able to do this, user.

Attached: download.jpg (286x176, 8K)

Other urls found in this thread:

mlpy.sourceforge.net/docs/3.5/lcs.html#mlpy.lcs_std
en.wikipedia.org/wiki/Longest_palindromic_substring
twitter.com/SFWRedditGifs

bump

Did you know you can google that homework problem, friend?

import mlpy

def lcp(s):
s = [ord(x) for x in s]
return mlpy.lcs_std(s, s[::-1])[0]

>import solution
>solution.do(muh_data)

Reducing a specific problem to a well understood classic problem is a lot more useful than some shitty adhoc solution.

wrong
>The longest palindromic substring problem should not be confused with the different problem of finding the longest palindromic subsequence

Tell me again why people want these jobs so badly?

What are you on about?
Substring is just the subsequence of a string.
And to get the length of the longest palindromic substring you have to find it first.

Thank you for your time, but we've decided to not continue on account of your argumentative approach and lack of attention to detail.

Srsly m8, learn the difference between subsequence and substring (subsequence where all elements are consecutive). What you wrote finds the longest palindromic subsequence, it's even in the bloody mlpy docs:
mlpy.sourceforge.net/docs/3.5/lcs.html#mlpy.lcs_std
And go argue with Wikipedia:
en.wikipedia.org/wiki/Longest_palindromic_substring

Stop embarrassing yourself.

Friendly reminder that you should be able to do this in linear time, some random dude did it 43 years ago.

Oh wow, you're actually right.
My bad.

Cheers for the tone switch.
Yeah, that's a common enough mix up that it's mentioned in multiple places - both the LPS article and the substring and subsequence ones.
Happens to most of us, in any case.

Substring is not same as subsequence....
Well. I have learned something today.

bool is_palindromic(char* str, int start, int end){
while(start

>O(n^3)

>while(startreturn max;
>}

>perform obtuse, minimal use case problems or you're a BRAINLET
I dont have a problem with these kinds of problems except when its tedious string analysis. Strings are almost always a pain in the cock to manipulate and analyze programmatically and its almost never needed in production.

>working solution is provided
>NO YOURE WRONG
Did you want a solution or not? Nobody expects optimization in a whiteboard problem

>Nobody expects optimization in a whiteboard problem

fuck you

That's right though.
If he doesn't tell you that he wants a solution with a certain run time then it doesn't matter.

It seems you are lost, friend.
Here:

It's not a bad idea to qualify your code with "shit perf tho, we can optimize it to quadratic or even linear" disclaimers, so they don't mistake you for a pajeet

Well, if Chad is also applying for the same position and his algorithm is more efficient, we will of course hire Chad instead of you Pajeet.

Only matters if the function is a bottleneck, which string manipulators never are, because once again theyre never used

Eh, depends.
If Chad wastes a lot of time optimizing the code without being asked to, I'd hire the other guy.

Which is something you should say to the interviewers, lest they think you're part of the "complexity, what's that?" generation, or a "small-scale complexity instead of whole-solution priorities" autist.

Nice leetcode copy, heres my DP solution


def longestPalindrome(self, s):
"""
:type s: str
:rtype: str
"""

l = len(s)
longest = s[0:1]

dp = [ [0] * l for _ in range(l)]

dp[l-1][l-1] = 1

for i in range(0,l-1): # Compute length 1 and 2 palindromes
dp[i][i] = 1
if s[i] == s[i+1]:
dp[i][i+1] = 1
longest=s[i:i+2]

for palLen in range(2,l): # Compute length 3+ palindromes based on the previous init of 1 and 2
for i in range(0, l-palLen):
j = i + palLen
if dp[i+1][j-1] > 0 and s[i] == s[j]:
dp[i][j] = 1
if j-i+1 > len(longest):
longest = s[i:j+1]
return longest

Okay so add a single comment at the top that just says "unoptimized solution"

>if the function is a bottleneck, which string manipulators never are, because once again theyre never used
>what is bioinformatics

Bioinformatics leverages parrallel computing not single threaded O(n^x) classic algorithms

Maybe python isn't that hard

>7 rounds of interviewing
>software engineering manager
What kind of shitty company is this, and why the fuck are we wasting our time with it.

>implying your NEET status is going to impress other companies

Just because you've never gotten a job doing actual programming doesn't mean the rest of us don't know what's involved in the interviewing process.

>Deshawn

Attached: 1509555034185.png (640x640, 411K)

yep, that's a good idea

>parallel computing is magic fairy dust that doesn't involve time/space complexity
oh boy

in erlang it's basically magic fairy dust

>in erlang it's basically magic fairy dust
sure, that's the boilerplate taken care for you
still
>in erlang it's basically magic fairy dust that still runs slower or faster depending on the algorithm's time complexity

How many rounds are there going to be?