Amazon interview: malloc32 Align & Space reduction


  • 1
    K

    2 Questions that were asked at Amazon for a SW Engineer position:
    1 - You should write malloc32+free32 function:
    * malloc32 should always returns an address that is dividable by 32.
    * you can't use (modulus operator) %.
    * free32 should free the whole allocated space.
    * Time Complexity and space Complexity should be O(1)
    * assumption: Time and Space Complexity of malloc is O(1).
    2 - given a string you should reduce the number of adjacent spaces as follows:
    * if there is more than 1 consecutive spaces it should be reduced to one.
    * if there is 1 or 0 space it should stay the same.
    Time complexity: O(n)
    Space complexity: O(1)


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.