回复: 3
跳转到指定楼层
上一主题 下一主题
收起左侧

Atlassian 悉尼OA题目和答案!

全局:

2019(4-6月) 码农类General 本科 实习@atlassian - 猎头 - 在线笔试  | | Pass | 其他

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
上一篇误点击发送。。。不知道能不能删除啊。
题主是四月10号被recruiter在LinkedIn上联系才申请的。然后申请完立马给了oa,但一直拖着没有做,期间recruiter催了一次。我昨天刚刚做完


以下是悉尼的试题(附代码):

1. Simple Max Difference:
Given an array arr[] of integers, find out the maximum difference between any two elements such that larger element appears after the smaller number.
Input : arr = {2, 3, 10, 6, 4, 8, 1}
Output : 8
Explanation : The maximum difference is between 10 and 2.

Input : arr = {7, 9, 5, 6, 3, 2}
Output : 2
Explanation : The maximum difference is between 9 and 7.
  1. def maxDiff(arr):
  2.     max_diff = arr[1] - arr[0]
  3.     min_element = arr[0]
  4.       
  5.     for i in range( 1, len(arr)):
  6.         if (arr[i] - min_element > max_diff):
  7.             max_diff = arr[i] - min_element
  8.       
  9.         if (arr[i] < min_element):
  10.             min_element = arr[i]
  11.     return max_diff
  12.       
复制代码



2. bouquets of Flowers:
Lara owns a flower shop, where she sells only two types of flower bouquets:

Type 1: The first type of bouquet contains three roses and costs p dollars.
Type 2: The second type of bouquet contains one cosmos and one rose and costs q dollars.
Lara grows these flowers in her own garden in a single row. You can consider the row as a one-dimensional array where each cell either contains a rose or a cosmos. For example array 001101011, here 0 indicates rose and 1 indicates cosmos.
There is an important rule that Lara follows when she makes the bouquets: she makes each bouquet with only consecutive flowers from the array. For example, in a bouquet, the flower from consecutive indices (i, i+1, and i+2) in the array can be present, but not from non-consecutive indices (i and i+2). In the array above, Lara can’t make any bouquets of type 1 but she can make 3 bouquets of type 2.

Now she wonders what is the maximum profit she can make if she makes these bouquets optimally. You are given a binary string representing her garden row. Calculate the maximum profit Lara can make. Remember it’s not necessary to use all the flowers.

Function Description

Complete the flowerBouquets function in the editor below. The function must return an integer denoting the maximum profit Lara can make if she makes her bouquets optimally.

3. longest chain:
Given an array, words, of n word strings (words[0], words[1],..., words[n-1]), choose a word from it and, in each step, remove a single letter from the chosen word if and only if doing so yields another word that is already in the library. Each successive character removal should be performed on the result of the previous removal, and you cannot remove a character if the resulting string is not an element in words(see Explanation below for detail). The length of a string chain is the maximum number of strings in a chain of successive character removals.

Complete the longestChain function in your editor. It has 1 parameter: an array of n strings, words, where the value of each element words; (where 0 <= i < n) is a word. It must return single integer denoting the length of the longest possible string chain in words.

Input Format
The locked stub code in your editor reads the following input from stdin and passes it to your function: The fist line contains an integer. n, the size of the words array. Each line i of the n subsequent lines (where 0 <= i < n) contains an integer describing the respective strings in words.

Constraints
1 <= n <= 50000

1 <= |words_i| <= 50, where 0 <= i < n

Each string in words is composed of lowercase ASCII letters.

Output Format
Your function must return a single integer denoting the length of the longest chain of character removals possible.

  1. import java.util.Arrays;
  2. import java.util.HashMap;
  3. import java.util.HashSet;

  4. public class LongestChain {

  5.     public static void main(String[] args) {
  6.         String[] words = {
  7.                 "a",
  8.                 "b",
  9.                 "ba",
  10.                 "bca",
  11.                 "bda",
  12.                 "bdca"
  13.         };

  14.         System.out.println("Longest Chain Length : " + longest_chain(words));
  15.     }

  16.     static int longest_chain(String[] w) {
  17.         if (null == w || w.length < 1) {
  18.             return 0;
  19.         }

  20.         int maxChainLen = 0;

  21.         HashSet<String> words = new HashSet<>(Arrays.asList(w));
  22.         HashMap<String, Integer> wordToLongestChain = new HashMap<>();

  23.         for (String word : w) {
  24.             if (maxChainLen > word.length()) {
  25.                 continue;
  26.             }
  27.             int curChainLen = find_chain_len(word, words, wordToLongestChain) + 1;
  28.             wordToLongestChain.put(word, curChainLen);
  29.             maxChainLen = Math.max(maxChainLen, curChainLen);
  30.         }
  31.         return maxChainLen;
  32.     }

  33.     static int find_chain_len(String word, HashSet<String> words, HashMap<String, Integer> wordToLongestChain) {
  34.         int curChainLen = 0;

  35.         for (int i = 0; i < word.length(); i++) {
  36.             String nextWord = word.substring(0, i) + word.substring(i + 1);
  37.             if (words.contains(nextWord)) {
  38.                 if (wordToLongestChain.containsKey(nextWord)) {
  39.                     curChainLen = Math.max(curChainLen, wordToLongestChain.get(nextWord));
  40.                 } else {
  41.                     int nextWordChainLen = find_chain_len(nextWord, words, wordToLongestChain);
  42.                     curChainLen = Math.max(curChainLen, nextWordChainLen + 1);
  43.                 }
  44.             }
  45.         }

  46.         return curChainLen;
  47.     }
  48. }
复制代码



4.Fun with Anagram:
Given a list of words, if there's anagram of such word coming afterwards, delete them:
Sample: [Code, cdoe, deoc, framer, frame] ==> [code, framer, frame]

  1. def anagram( s, t):
  2.         # write your code here
  3.         # write your code here
  4.         set_s = [0] * 256
  5.         set_t = [0] * 256
  6.         for i in range(0, len(s)):
  7.             set_s[ord(s[i])] += 1
  8.         for i in range(0, len(t)):
  9.             set_t[ord(t[i])] += 1
  10.         for i in range(0, 256):
  11.             if set_s[i] != set_t[i]:
  12.                 return False
  13.         return True

  14. def funWithAnagram(list):
  15. res = []
  16. anagram = False
  17. for word in list:
  18. for element in res:
  19. if anagram(element, word):
  20. anagram = True
  21. break

  22. if Anagram = False:
  23. res.append(word)
  24. else:
  25. anagram = True

  26. return res
复制代码



5. Initial Public Offering

挺简单的没截图。

加个米呗 谢谢

评分

参与人数 5大米 +46 收起 理由
a4839500 + 2 给你点个赞!
JadeWang + 1 很有用的信息!
Kyrazzzzz + 2 很有用的信息!
匿名用户-IFHBA + 40
eggface + 1 给你点个赞!

查看全部评分


上一篇:巨硬某光学team昂塞过经
下一篇:FB面经
🔗
eggface 2019-5-30 21:21:58 | 只看该作者
全局:
有onsite么?现在onsite要自己带电脑做题么?
回复

使用道具 举报

🔗
 楼主| cecilianxf 2019-5-30 22:12:31 | 只看该作者
全局:
eggface 发表于 2019-5-30 21:21
有onsite么?现在onsite要自己带电脑做题么?

有onsite。
可以带可以不带,我选择带。
onsite在下月中旬到时候在更新吧
回复

使用道具 举报

🔗
y75475 2022-2-10 23:38:06 | 只看该作者
全局:
第四题代码格式不对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表