Issue # 3: IT training - current issues and challenges from leading companies

    This week ends with a selection of tasks and questions that are often given during interviews on Facebook . Tasks chose different difficulty levels from “Easy” to “Hard”. The condition was again left in English. We’ll attach the solutions in a comment in a week. Good luck!

    Questions:

    1. Do you want to start the animation in half a second after the user clicks the button. What is the best way to do this?

    2. The photo sharing application displays a system notification when a user receives a photo. Your application should display a photo when a user deletes a notification. Which of the following do you need to associate with the Notification object that you submit to Notification Manager?

    Tasks:

    1.
    Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.
    For example, given nums = [0, 1, 0, 3, 12], after calling your function, numsshould be [1, 3, 12, 0, 0].
    Note:
    You must do this in-place without making a copy of the array.
    Minimize the total number of operations.


    2.
    Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead.

    Note:
    The sum of the entire nums array is guaranteed to fit within the 32-bit signed integer range.

    Example 1 :

    Given nums = [1, -1, 5, -2, 3], k = 3,
    return 4. (because the subarray [1, -1, 5, -2] sumsto 3and is the longest)

    Example 2 :

    Given nums = [-2, -1, 2, 1], k = 1,
    return 2. (because the subarray [-1, 2] sumsto 1and is the longest)

    Follow Up:
    Can you do it in O (n) time?


    3.
    Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.

    Note : The input string may contain letters other than the parentheses (and).

    Examples:
    "()())()" -> ["()()()", "(())()"]
    "(a)())()" -> ["(a)()()", "(a())()"]
    ")(" -> [""]

    Also popular now: