Interview Query

ByteDance Data Scientist | October 2020

Company: Bytedance

Position: Data Scientist

Location: nan

Level: Mid-level

Outcome: NA

How was the interview process? What was it like?

The interview was quite great. All the people that I interviewed were PHD holders. In all the interviews the approach to the question was tested more than getting the correct solution

What technical questions were asked?

Python / Pandas, Data Structures and Algorithms, SQL / Analytics, ML Implementation/Engineering System Design, Probability, Modeling and ML Knowledge, Product Metrics and Analytical

What was one of your solutions?

First Solution is the brute force approach
Loop through all the elements and find the element's index
def get_ele_index(arr, target):
    out = -1
    for i in range(len(arr)):
        if arr[i] == target:
            out = i
    return out
For solving it in o(logn) you can use binary search
First binary search for finding the pivot
Then binary search again for finding the element
def find_pivot(arr, low, high):
    mid = int((low + high)/2)
    if arr[mid] > arr[mid+1]:
        return mid+1
    else:
        if arr[low] > arr[mid]:
            find_pivot(arr, low, mid)
        else:
            find_pivot(arr, mid, high)
def binary_Search(arr, ele, low, high):
    mid = int((high+low)/2)
    print(arr, mid, arr[mid], ele, arr[mid] == ele)
    if arr[mid] == ele:
        return mid
    elif arr[mid] > ele:
        mid = binary_Search(arr, ele, low, mid)
    else:
        mid = binary_Search(arr, ele, mid, high)
    return mid
def find_element(arr, ele):
    pivot_index = find_pivot(arr, 0, len(arr)-1)
    print(pivot_index, arr)
    if ele < arr[-1]:
        return binary_Search(arr, ele, pivot_index, len(arr)-1)
    else:
        return binary_Search(arr, ele, 0, pivot_index)

0 Comments

Sort By: Default

Edit Post

Tag your post (e.g. "Amazon", "Data Scientist" ...)

Preview