Amazon OA
Amazon OA
Tech In Pieces
这个作者很懒,什么都没留下…
展开
-
Amazon OA 2021 from Aonecode.com
Refer: Amazon OAAmazon Online Assessment has 2 sessions - OA1 and OA2. OA1 consists of 7 Debugging, 24 Reasoning/Logic and 1 Coding problem.下面两个链接:https://aonecode.com/amazon-online-assessmenthttps://aonecode.com/amazon-online-assessment-questions题目和解原创 2021-01-08 05:00:02 · 2897 阅读 · 0 评论 -
Merge Two Sorted Lists
it’s like the “merge” part in merge sort.pay attention, it is required that:The new list should be made by splicing together the nodes of the first two lists.so that means we can’t have a new linkedlist. and we can only do something on those two given l原创 2020-09-14 00:13:36 · 114 阅读 · 0 评论 -
Add Two Numbers
add two linkedlist.example:Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)Output: 7 -> 0 -> 8Explanation: 342 + 465 = 807.and the solutions will be like follows:class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) {原创 2020-09-13 23:28:43 · 61 阅读 · 0 评论 -
Trapping Rain Water
another classic problem.原创 2020-09-13 23:00:08 · 58 阅读 · 0 评论 -
Reorder Log Files
You have an array of logs. Each log is a space delimited string of words.For each log, the first word in each log is an alphanumeric identifier. Then, either:Each word after the identifier will consist only of lowercase letters, or;Each word after the原创 2020-09-13 09:56:57 · 143 阅读 · 0 评论 -
Most Common Word
Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at least one word that isn’t banned, and that the answer is unique.Words in the list of banned words are given原创 2020-09-13 09:19:51 · 152 阅读 · 0 评论 -
Valid Parentheses
classic stack problem.class Solution { public boolean isValid(String s) { if (s == null || s.length() == 0) return false; if (s.length() % 2 == 1) return false; Stack<Character> stack = new Stack<>();原创 2020-09-13 01:15:22 · 54 阅读 · 0 评论 -
First Unique Character in a String
Given a string, find the first non-repeating character in it and return its index. If it doesn’t exist, return -1.unique->hashset.but hashset can only do binary things, like if I find again, the only way to show I found again is remove this key, but w原创 2020-09-13 00:45:31 · 73 阅读 · 0 评论 -
Integer to English Words
essentially, this is exactly the same with Integer to Roman or Integer to any other calculate method.I hate questions like this, let’s hope I won’t met problems like this in a real interview.class Solution { String[] less20 = {"", "One", "Two", "Thre原创 2020-09-13 00:13:06 · 93 阅读 · 0 评论 -
Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.do it in linear time complexity and constant extra space.iterate them once, and we can only use swap (at least it looks like we have to do原创 2020-09-12 23:54:22 · 61 阅读 · 0 评论 -
Compare Version Numbers
given two version numbers in the format of string, if 1>2, return 1, else if 1<2, return -1, else return 0.so it’s like a new comparator.but an easy problem like this, you can’t even solve it.followings are the shit code you wrote.class Solution原创 2020-09-12 12:20:33 · 143 阅读 · 0 评论 -
Minimum Window Substring (Unsolved)
given two strings, say it’s S and T.we need to find the minimum windows in S that contains every chars in T, and we don’t need them to be in the exactly same order.please do this in a time complexity of O(N)other things needs to keep in mind:if there i原创 2020-09-12 11:26:30 · 173 阅读 · 0 评论 -
Group Anagrams
given an array of strings, return a 2d array that each element in that is a grouped array contains anagrams.first, we need to iterate this array at least once.and then, we need to group them based on the exactly same characters they used. but how can we原创 2020-09-12 01:15:13 · 75 阅读 · 0 评论 -
Rotate Image
Rotate a matrix clockwise, 90 degree.do it in-place.how to do it in place?remember, do it in place doesn’t mean that we don’t need extra space. in fact, we do.so if we takes an element and put it down in its new place, the original element here will be原创 2020-09-11 11:13:02 · 66 阅读 · 0 评论 -
Implement strStr()
basically, we need to implement indexOf()so this problem is actually a string matching problem.we met many of such algorithm原创 2020-09-11 10:47:26 · 116 阅读 · 0 评论 -
3 Sum Closest
now we need find the triplet in a given array.we only need to find the closest triplets and return it, that’s all.first, we know there is a limitness of being close, 0, so if we find something which sums to exactly the target, and then we break.but if w原创 2020-09-08 11:56:16 · 111 阅读 · 0 评论 -
3 Sum
classic sum problems.given an array may contains duplicates, return all the unique triplet which sum equals to 0.a classic way is to presort it, and use three pointers, the first one will be single direction, and the other two will be opposite direction原创 2020-09-07 23:48:23 · 71 阅读 · 0 评论 -
Integer to Roman
given rules, to some kind of covert stuff.class Solution { public String intToRoman(int num) { int[] decimal = {1000,900,500,400,100,90,50,40,10,9,5,4,1}; String[] roman = {"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};原创 2020-09-07 11:19:54 · 61 阅读 · 0 评论 -
Container With Most Water
classic water container problems.using left and right pointer. find the one that constraint the height of this container, and move to find a potential larger one.class Solution { public int maxArea(int[] height) { int res = 0; int l =原创 2020-09-07 11:16:07 · 73 阅读 · 0 评论