PayPal Data Structures & Algorithms Interview Questions

Review this list of 8 PayPal data structures & algorithms software engineer interview questions and answers verified by hiring managers and candidates.
  • PayPal logoAsked at PayPal 
    +16

    "We can use dictionary to store cache items so that our read / write operations will be O(1). Each time we read or update an existing record, we have to ensure the item is moved to the back of the cache. This will allow us to evict the first item in the cache whenever the cache is full and we need to add new records also making our eviction O(1) Instead of normal dictionary, we will use ordered dictionary to store cache items. This will allow us to efficiently move items to back of the cache a"

    Alfred O. - "We can use dictionary to store cache items so that our read / write operations will be O(1). Each time we read or update an existing record, we have to ensure the item is moved to the back of the cache. This will allow us to evict the first item in the cache whenever the cache is full and we need to add new records also making our eviction O(1) Instead of normal dictionary, we will use ordered dictionary to store cache items. This will allow us to efficiently move items to back of the cache a"See full answer

    Software Engineer
    Data Structures & Algorithms
    +6 more
  • PayPal logoAsked at PayPal 
    +9

    "we can use two pointer + set like maintain i,j and also insert jth character to set like while set size is equal to our window j-i+1 then maximize our answer and increase jth pointer till last index"

    Kishor J. - "we can use two pointer + set like maintain i,j and also insert jth character to set like while set size is equal to our window j-i+1 then maximize our answer and increase jth pointer till last index"See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • PayPal logoAsked at PayPal 
    Video answer for 'Find the median of two sorted arrays.'
    Software Engineer
    Data Structures & Algorithms
    +4 more
  • PayPal logoAsked at PayPal 
    Video answer for 'Given an nxn grid of 1s and 0s, return the number of islands in the input.'
    +9

    " from typing import List def getnumberof_islands(binaryMatrix: List[List[int]]) -> int: if not binaryMatrix: return 0 rows = len(binaryMatrix) cols = len(binaryMatrix[0]) islands = 0 for r in range(rows): for c in range(cols): if binaryMatrixr == 1: islands += 1 dfs(binaryMatrix, r, c) return islands def dfs(grid, r, c): if ( r = len(grid) "

    Rick E. - " from typing import List def getnumberof_islands(binaryMatrix: List[List[int]]) -> int: if not binaryMatrix: return 0 rows = len(binaryMatrix) cols = len(binaryMatrix[0]) islands = 0 for r in range(rows): for c in range(cols): if binaryMatrixr == 1: islands += 1 dfs(binaryMatrix, r, c) return islands def dfs(grid, r, c): if ( r = len(grid) "See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • PayPal logoAsked at PayPal 
    Video answer for 'Given stock prices for the next n days, how can you maximize your profit by buying or selling one share per day?'
    +9

    "from typing import List def maxprofitgreedy(stock_prices: List[int]) -> int: l=0 # buying r=1 # selling max_profit=0 while rstock_prices[l]: profit=stockprices[r]-stockprices[l] maxprofit=max(maxprofit,profit) else: l=r r+=1 return max_profit debug your code below print(maxprofitgreedy([7, 1, 5, 3, 6, 4])) `"

    Prajwal M. - "from typing import List def maxprofitgreedy(stock_prices: List[int]) -> int: l=0 # buying r=1 # selling max_profit=0 while rstock_prices[l]: profit=stockprices[r]-stockprices[l] maxprofit=max(maxprofit,profit) else: l=r r+=1 return max_profit debug your code below print(maxprofitgreedy([7, 1, 5, 3, 6, 4])) `"See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • 🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.

  • PayPal logoAsked at PayPal 
    +37

    "a. Sort the array elements. b. take two pointers at index 0 and index Len-1; c. if the sum at the two pointers is target; break and return the pair d. if the sum is smaller, then move left pointer by 1 e. else move right pointer by 1; run the logic till the target is met or right pointer crosses the left pointer."

    Komal S. - "a. Sort the array elements. b. take two pointers at index 0 and index Len-1; c. if the sum at the two pointers is target; break and return the pair d. if the sum is smaller, then move left pointer by 1 e. else move right pointer by 1; run the logic till the target is met or right pointer crosses the left pointer."See full answer

    Software Engineer
    Data Structures & Algorithms
    +5 more
  • PayPal logoAsked at PayPal 

    "int[] sqSorted(int[] nums) { int i = 0, j = nums.length-1; int k = nums.length-1; int[] sqs = new int[nums.length]; while(i n1) { sqs[k--] = n2; j--; } else { sqs[k--] = n1; i++; } } for(int n: sqs) System.out.println(n); return sqs; }"

    Mahaboob P. - "int[] sqSorted(int[] nums) { int i = 0, j = nums.length-1; int k = nums.length-1; int[] sqs = new int[nums.length]; while(i n1) { sqs[k--] = n2; j--; } else { sqs[k--] = n1; i++; } } for(int n: sqs) System.out.println(n); return sqs; }"See full answer

    Software Engineer
    Data Structures & Algorithms
    +2 more
  • PayPal logoAsked at PayPal 
    +7

    "def traprainwater(height: List[int]) -> int: n = len(height) totalwaterlevel = 0 for i in range(n): j = i+1 while j = n: break rows = j - i -1 intrwaterlevel = min(height[j], height[i]) * rows for k in range(i+1, j): intrwaterlevel -= height[k] totalwaterlevel += intrwaterlevel i = j return totalwaterlevel"

    Manoj R. - "def traprainwater(height: List[int]) -> int: n = len(height) totalwaterlevel = 0 for i in range(n): j = i+1 while j = n: break rows = j - i -1 intrwaterlevel = min(height[j], height[i]) * rows for k in range(i+1, j): intrwaterlevel -= height[k] totalwaterlevel += intrwaterlevel i = j return totalwaterlevel"See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
Showing 1-8 of 8