高盛 OA

共 90 分钟

第一题

Grid Game

Given a grid with n rows and m columns of binary integers, 0 or 1, and a set of rules, simulate k turns of the game on this grid. The given grid denotes the initial configuration for the game, where grid[ i][j] = 1 denotes that cell in the ith row and jth column is alive, and grid[ i][j] = 0 denotes that this cell is dead. Two cells are neighbors when they share at least one common corner, thus each cell has at most 8 neighbors, as shown in the picture below:

There is a list of 9 rules indexed from 0 to 8, each rule having a value of either “alive” or “dead”. A single rule,i, specifies what happens to the cells with exactly i alive neighbors. In each turn the new value of a cell is determined by counting the number of ‘alive’ neighbors and applying the rule at index corresponding to the count. The value corresponding to the rule is used to set new value in the cell.

As an example, consider a rule set where rules at indices 3 and 5 are ‘alive’. All of the other rules are ‘dead’. The following shows the process for two turns starting with the grid given in turn 0:

The “Live neighbors for each cell” grid at turn 1 contains the number of adjoining live cells at each grid position for turn 0. It is used to create the new grid state for turn 1. At each cell with a value of 3 or 5, the related cell in the new grid is set to alive. All of the others are set to dead. The resultant grid is similarly analyzed for the second turn. The returned 2-dimensional array contains the grid rows shown at turn 2 above.

Function Description

Complete the function gridGame in the editor below. The function must return a 2-dimensional integer array.

gridGame has the following parameter(s):
grid[grid[0][0],…grid[n-1][m-1]]: a 2D array of integers that denote the original grid
k: an integer that denotes the number of steps to perform
rules[rules[0],…rules[8]]: an array of strings that represent the rules of the game

Constraints

• 1 <= n*m <= 10^3
• 0 <= k <= 10^3
• rules[r] is either “dead” or “alive” (where 0 <= r < 9)

第二题

再转个帖子

大家好,小弟new grad,7.4海投高盛Analyst工程师岗,拿来练练手,7.11收到OA,周末刚做完

2道题,90分钟

第一题,给定字符串,如’ABCCBABA’,‘ACBXXBCA’,找出至少含有’ABC’各一个(顺序无所谓)的子字符串的总数,只有O(n)的时间复杂度能过所有case,用双指针就好
第一题是林口期溜.
第二题,林口三奇斯,不过还要只返回质数,没有跑过所有case,主要是超时,没想通.


问一下 楼主是投的 校招2020 New Analyst 项目吗? 怎么选择工程师岗位呢?

对的是那个项目,就网申点开之后一步步往下填就有可以选择engineering的
OA相关资料的话我看论坛里好像还有其他面经帖子有说到吧,不好意思我自己没有特别上心去整理


请问楼主投的时候有让你选是数学 还是数学编程 还是编程吗

我的没有让我选,就只有coding,我也是纳闷儿还反复确认了好几遍,可能是跟选的岗位分类有关?猜的……


请问楼主选了啥岗位 只有engineer相关吗

对的,我特意查了下网申的问题,确实有问到,在Engineering - Questions里有问:
Please indicate which of the below profiles best represent the type of work you’re interested in. (select all that you’re interested in)
We want to learn more about your technical skills and the types of problems that you’re interested in solving. We gather this feedback throughout the recruiting and interview process. As part of this, we ask that you complete an online technical assessment. Please select which test you want to complete based on your area(s) of knowledge and/or interest. (select one)

补充新出炉的OA题

还有一道 Spiral Matrix LeetCode - The World's Leading Online Programming Learning Platform 变种,output should return the prime numbers in the matrix while traversed in a spiral order

Lemon gave George a grid and wants him to traverse the 964 9, spiral order. TO check whether George Is doing It correctly, Lauren asked him to report all the primes as they are encountered. Help George to find these primes wide traversing the grid in spiral order.
For example, grid [[7,7,3,8,1], [13, 5, 4,5, 2], [9, 2,12,3, 9],[6,12,1, 11, 41]]with the number of rows, n = 4, and the number of columns, m = 5. Traversal is as follows:

image

The traversal order is: [7, 7,3,8,1,2, 9, 41, 11, 1, 12, 6, 9, 13, 5, 4,5, 3,12, 2] and primes as encountered in the tNversal are [7, 7, 3, 2,41,11,13, 5,5, 3, 2j. Note that 1 is not a prime number.
Function Description

Complete the function spiralOrderPrimes in the editor below. The function must return an array of integers that denote the primes in the grid in the spiral order traversal. Spirals start from the left. spiralOrderPrimes has the following parameter(s):
grid[grid[0][0]…grid[n-1][m-1]]: a 2D array of integers


Examples:-
Input - ABC
Output - 1

Input - ABCCBA
Ouput - 7

Input - PQACBA
Output - 7

补充一个OA题目 LC 1010 Pairs of Songs With Total Durations Divisible by 60

网申后4,5天拿到的OA
我记得申请的时候让选是coding还是coding+math,我选的coding
90 分钟两道coding
第一道split array
第二道感觉跟莉蔻而把酒差不多

请问一下,我在申请页面里 选可以工作的地址,北美都没有engineering可以选了,如果我选了北京,未来有机会可以match到美国的组吗?

机会很小

new grad,网上海投的,master学位
我是在 new analyst 里面选的 engineering,两道题

  1. Find the Rank:给一个list,分别是几个学生的各项考试分。要求返还总分排名为n的学生是哪个
  2. Spiral Matrix:和lc原题类似,论坛里也有原题,转圈儿打印matrix里的prime number。但是数都贼大,贼容易超时

Are solutions available for these? Will O(kmn) work in grid question?
Thank you.