Uber ATG 店面和上门面经

店面考的是

Given an array of n integers nums and an int target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition nums[i] + nums[j] + nums[k] > target.

Example:

Input: nums = [2, 1, 3, 0, 3], target = 5
Output: 5
Explanation:
[0, 3, 3]
[1, 3, 3]
[1, 2, 3]
[1, 2, 3]
[2, 3, 3]

类似 https://leetcode.com/problems/3sum-smaller

onsite 两轮系统设计,两轮coding
coding题目报一下

第一题

Given an unordered list of pairs where each pair represents a parent-child relationship (not nessesary direct) in an N-ary tree. Reconstruct and return the original tree. You can assume that each node has a unique value.

Example 1:

Input: [[1, 2], [1, 3], [1, 4], [2, 4]]
Output:

     1
    / \
   2   3
  /
 4

Example 2:

Input: [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 4], [2, 5], [2, 7], [3, 6], [4, 7]]
Output:

      1
     / \
    2   3
   / \   \
  4   5   6
 /
7
第二题

Given a positive int n, print all jumping numbers smaller than or equal to n. A number is called a jumping number if all adjacent digits in it differ by 1. For example, 8987 and 4343456 are jumping numbers, but 796 and 89098 are not. All single digit numbers are considered as jumping numbers.

Example:

Input: 105
Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 21, 23, 32, 34, 43, 45, 54, 56, 65, 67, 76, 78, 87, 89, 98, 101]