Palindrome one character removed (Python Interview)

preview_player
Показать описание

Watch someone try to solve the Palindrome one character removed problem in Python with a Facebook engineer.

TIMESTAMPS:

00:00 - Intro
1:42 - Question 1 Palindrome One Character Removed
21:00 - Question 2 Balancing Parenthesis
50:30 - Question 3 Word Search
Рекомендации по теме
Комментарии
Автор

So the interviewer didn't catch in either Question 1 or 2 that "if not string" is super ambiguous and can lead to unexpected behaviors with different data types. The function in Question 1 would say the integer 0, None, False, etc are all palindromes if a user passed any of those in as the value for string. Oversights such as that can lead to exploitable code flaws where important functions like authentication could be coerced to return True if passed unexpected input. IE if a web application that received JSON input leveraged a function with a similiar type of issue, a user could provide a maliciously crafted JSON input to the function containing a null or 0 where a string is expected to cause intended application behavior.

The safer way to handle that would be to check for if len(string) == 0 and also implement a check based on the datatype

(I am preparing for a security role, but sadly have to do leetcode too)

fitwizle_work
Автор

Really great job from the interviewee. Was crystal clear and very efficent in their solutions.

stefanballing
Автор

I think he should use more time to explain why he wants to use the two pointers and why he thinks moving the pointers can work with deleting a character.
I want to explain my thinking process, first I am thinking about dp because palindrome is often related to dp. But this is much easier, this question only asks to check whether a string is a palindrome. So we can use two pointers because it is clear and linear time complexity. If we could delete one character from this string to make palindrome, we can delete the left one or right one when two pointers are not equal. So we can choose to move the pointers by 1, and check whether any of the sub-strings is palindrome.

kyuan
Автор

You should move the name tags from the cursors and put them at the bottom of the screen as a color-coded legend/key so they don't cover up the code that's being typed.

fennecbesixdouze
Автор

How did he come up with those solutions? What's the natural thought process of a normal human to arrive at those solutions? I am 100% sure he just memorized. This is even more evident the moment he started putting weights as a dictionary with open bracket having a value of 1 and closed bracket having a value of -1. Unless he has seen the question before, no way he will be able to jump into the solution so quickly. Even the interviewer memorized the question(which obviously he should coz he is the one asking but its just so surprising to me) coz he mentions the stack approach which is the 1st approach on leetcode btw(😂).

All of mankind's brainpower is now being used to memorize just so we can vomit these solutions on a notepad in an interview. Such wasted potential.

blasttrash
join shbcf.ru