
Apple


Apple Interview Questions and Answers for Freshers
Q1. Kevin and his Fruits Problem Statement
Kevin has 'N' buckets, each consisting of a certain number of fruits. Kevin wants to eat at least 'M' fruits. He is looking to set a marker as high as possible such that i...read more
Find the marker value needed for Kevin to eat at least 'M' fruits from 'N' buckets.
Iterate through each test case and calculate the marker value needed based on the number of fruits in each bucket.
Subtract the marker value from the number of fruits in each bucket and check if the total is at least 'M'.
Return the highest possible marker value for each test case.
Q2. Minimum Umbrellas Problem
You are provided with ‘N’ types of umbrellas, where each umbrella type can shelter a certain number of people. Given an array UMBRELLA
that indicates the number of people each umbrella...read more
Given 'N' types of umbrellas with different capacities, find the minimum number of umbrellas required to shelter exactly 'M' people.
Iterate through the umbrella capacities and try to cover 'M' people using the minimum number of umbrellas.
Keep track of the total number of people covered and the number of umbrellas used.
If it is not possible to cover 'M' people exactly, return -1.
Return the minimum number of umbrellas required to shelter exactly 'M' people.
Q3. Lazy Santa Problem Statement
It's Christmas and Santa has 'K' gifts to distribute. There are 'N' children standing in a straight line in the park due to COVID restrictions. You are given an array distance
conta...read more
Find the minimum distance Santa must travel to distribute 'K' gifts to 'K' different children standing in a straight line.
Sort the array 'distance' to easily calculate the minimum distance Santa has to walk.
Calculate the difference between adjacent elements in the sorted array and sum the first 'K-1' differences to get the minimum distance.
Return the minimum distance Santa has to walk for each test case.
Q4. Ninja and Candies Problem
Ninja, a boy from Ninjaland, receives 1 coin every morning from his mother. He wants to purchase exactly 'N' candies. Each candy usually costs 2 coins, but it is available for 1 coin i...read more
Calculate the earliest day on which Ninja can buy all candies given the number of candy types, special offers, and Ninja's candy preferences.
Iterate through each day and check if any special offers are available for the candies Ninja wants to buy.
Keep track of the remaining candies Ninja needs to buy and the coins he has each day.
Consider both regular price and sale price while making purchases.
Return the earliest day on which Ninja can buy all candies.
Q5. Max GCD Pair Problem Statement
Given an array of positive integers, determine the Greatest Common Divisor (GCD) of a pair of elements such that it is the maximum among all possible pairs in the array. The GCD o...read more
Find the maximum GCD of a pair of elements in an array of positive integers.
Iterate through all pairs of elements in the array to find their GCD.
Keep track of the maximum GCD found so far.
Use Euclidean algorithm to calculate GCD efficiently.
Return the maximum GCD value found.
Q6. merge two sorted arrays to give a sorted array SV randomization constraints Code to generate sequence of powers of 2
Merge two sorted arrays to give a sorted array and generate sequence of powers of 2 using SV randomization constraints.
Create a new array to store the merged result
Use two pointers to iterate through the two sorted arrays and compare elements
Add the smaller element to the new array and move the pointer for that array
Continue this process until all elements are merged
To generate sequence of powers of 2, use SV randomization constraints to create a random sequence of powers of ...read more
Q7. What is the apple computer science
Q8. No of islands(graph)
Count the number of islands in a graph
Use Depth First Search (DFS) or Breadth First Search (BFS) to traverse the graph
Mark visited nodes to avoid revisiting them
Each connected component represents an island
Q9. Reverse a string
Reverse a string by iterating through the characters and swapping them
Create a function that takes a string as input
Initialize two pointers, one at the beginning and one at the end of the string
Swap the characters at the two pointers and move them towards the center until they meet
More about working at Apple

Top HR Questions asked in Apple for Freshers
Interview Process at Apple for Freshers

Top Interview Questions from Similar Companies








Reviews
Interviews
Salaries
Users/Month

