Grokking LinkedIn Coding Interview

0% completed

Hidden Document
Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content Hidden Document Content

.....

.....

.....

Like the course? Get enrolled and start learning!
Mohammed Dh Abbas

Mohammed Dh Abbas

· 2 years ago

I don't agree with official solution its way to complicated and not practice for interview session

class Solution: ''' first sort the array Then for each array element at i, j add elements at i and j now we need to find the remaining elements define start pointer that goes --> and pointer end that goes <-- to find the remaining elements since the array is sorted we know when move a start or end pointer add the elements at position start and end and see if this + the i, j additions = target -3, -1, 1, 1, 1, 1, 1, 2, 4 i j s --> <-- e ''' def searchQuadruplets(self, arr, target): quadruplets = [] seen = set() arr.sort() for i in range(len(arr) - 3): for j in range(i + 1, len(arr)
Show 1 reply