## Apple Interview Questions

- 0of 0 votes
An ABC notation in a tree is defined as folllows:

1. "0" means travel left

2. "1" means travel right

3. "Undefined" means hit the root

4. "Not Found" means not present in tree

Given a BST insertion order, {5,2,8,3,6,9,1} find the ABC notation for 6, 1, 10, 2 which is "10","00","NotFound", "0"

- 0of 0 votes
Apple On-site at Cupertino

Team Data Warehousing

Questions on Hadoop, Hive and Spark

I. Given a table with 1B of user ID and product IDs that the users bought, and another table with product ID mapped with product name. We are trying to find the paired products that are often purchased together by the same user, such as wine and bottle opener, chips and beer … How to find the top 100 of these co-existed pairs of products. If going with hadoop, where is the bottleneck and how to optimize?

II. Someone put distribute Random()*ID in a Hive script to prevent data skew. What would be the problem here?

- 0of 0 votes
Apple On-site at Cupertino

Team Data Warehousing

III. Given three letters ABC, where AB->C, AC->B, BC->A (sequence doesn’t matter). Get the length of the path to convert from a given string to a single character.

For example, “ABACB” goes to “ACCB” (based on AB ->C, convert s[1] and s[2] to C)

“ACCB” goes to “BCB” (based on AC->B)

“BCB” goes to “AB”

“AB” goes to “C”

So it takes 4 steps to change the given string into a single character.

If a given string cannot be resized to 1 character, such as “AAA” or "ABACABB", return -1.

- 0of 0 votes
Apple On-site at Cupertino

Team Data Warehousing

There were 6.5 rounds in total, that 0.5 on package negotiation with the HR and the remaining rounds with 2 managers and 4 engineers.

Only three pure coding questions were asked.

I. Use a stack to sort given data.

II. Given an array with positive integers only, find the MIN integer that is missing from the array.

- -7of 7 votes
wefa

- 0of 0 votes
We are speaking about a web page of Todo tasks.

I want the option to add task, edit task or delete task, and mark task as completed (or vice versa).

I also want the ability to filter the tasks by completion status (pending, completed, all).

Please accomplish one of the requirement using directive.

You should write this code in Java Angular

- 0of 0 votes
Write code to sum 2 integer but u cant use a+b method, you have to use either ++ or --. How you will handle negative numbers.

- 1of 1 vote
How can we divide a large file between multi threads to process it? If we are running a multi threaded application and input is a large file and we have to provide each thread a part of the file to make it fast. How we can achieve it in java?

- 0of 0 votes
There is a test automation running and fails 14%, say 1/7 times? How you will debug? There is no code change or test code change.

- 0of 0 votes
There are several words in a file. Get the occurrence of every word and sort it based on the occurrence, if more than one word is having same occurrence than sort it alphabetically.

- 0of 0 votes
We have one single linked list. How we’ll travers it that we reach till second last (n-1) node. If we want to reach till (n\2) node.

- 0of 0 votes
In a directory we have several big log files? How u’ll find it how many number of lines are there in file? Aggregated count for all the files. What is if multiple threads are using those files? How will u be assigning files to them? What if one file size is way bigger than others.

- 0of 0 votes
How can we get square of a number without using * or carrot sign.

- 0of 0 votes
Write a query which return 5 persons who had spent most from a table and table contains customer id, product id and expenses. Customer id can be duplicate.

- 0of 0 votes
There is 3 text file, like file1.txt, file2.txt etc. Every file contains customer id, product id and expenses. Now write java code which will return 5 persons who spent most in these three files. Customer id can be duplicate all over files.

- 0of 0 votes
How can we get the square of a number without using * or carrot sign.

- 2of 2 votes
Design a parking lot system where you need to provide a token with the parking space number on it to each new entry for the space closest to the entrance.

When someone leave you need update this space as empty.

What data structures will you use to perform the closest empty space tracking, plus finding what all spaces are occupied at a give time.

- 0of 0 votes
Find median from a stream of flowing numbers

- 0of 0 votes
given 2 arrays wrds[] , chars[] as an input to a function such that

wrds[] = [ "abc" , "baa" , "caan" , "an" , "banc" ]

chars[] = [ "a" , "a" , "n" , "c" , "b"]

Function should return the longest word from words[] which can be constructed from the chars in chars[] array.

for above example - "caan" , "banc" should be returned

Note: Once a character in chars[] array is used, it cant be used again.

eg: words[] = [ "aat" ]

characters[] = [ "a" , "t" ]

then word "aat" can't be constructed, since we've only 1 "a" in chars[].

- 0of 0 votes
Explain some of the text encoding types and advantages/disadvantages of each.

- 0of 0 votes
If your browser crashes, how would you debug it only using the command line?

- 0of 0 votes
There are 3 ants at 3 corners of an equilateral triangle they randomly start moving towards another corner what is the probability that they do not collide? Follow up: Suppose if all ants go in same direction(say ant 1 travels from point A to B, ant 2 from B to C and ant 3 from C to A. Either all ant travels in clockwise or anti clockwise) when will they collide

- 0of 0 votes
design an iterator over a LinkedList of LinkedList's

- 0of 0 votes
How will you sort 1 billion integers stored in an array?

- 1of 1 vote
Having two distinct very large ordered array of values, find the mean value(not median) of the two arrays.

- 2of 2 votes
You have a 100 coins laying flat on a table, each with a head side and a tail side. 10 of them are heads up, 90 are tails up. You can't feel, see or in any other way find out which side is up. Split the coins into two piles such that there are the same number of heads in each pile.

- 0of 0 votes
Model an elevator.

- 1of 1 vote
Implement an iterator for a binary search tree that will iterate the nodes by value in ascending order

- -6of 6 votes
how we make a spftwre for pc

- 0of 0 votes
Reimplement this code so that its results will always be the same, but that it does not cause a stack overflow on large inputs. Your solution must still implement the Folder interface.

Coding

Your class must be named iteration.MyFolder`package iteration; import java.util.Queue; public class MyFolder<T, U> implements Folder<T, U> { public U fold(U u, Queue<T> ts, Function2<T, U, U> function) { if(u == null || ts == null || function == null) throw new IllegalArgumentException(); if (ts.isEmpty()) { return u; } // The recursive implementation will overflow the stack for // any data set of real size, your job is to implement a // non-recursive solution // return fold(function.apply(ts.poll(), u), ts, function); return null; } } package iteration; import java.util.Queue; public interface Folder<T, U> { U fold(U u, Queue<T> list, Function2<T, U, U> function); } package iteration; public interface Function2<T, U, R> { R apply(T t, U u); }`