Questions d'entretiens - Android developer intern

6 k

Questions d'entretien pour Android Developer Intern partagées par les candidats

Principales questions d'entretien

Trier: Pertinence|Populaires|Date
On a demandé à Android Developer...21 mai 2015

Given an array of ints = [6, 4, 0, 5, 0, 0, 0, 1, 0] move all non zero numbers to the left and zeros to the right. How can you now improve your answer to O(n)?

21 réponses

Just keep pointers to the first and last elements of a new array. private static int[] moveZerosToLeft(int[] arr) { int first = 0; int last = arr.length - 1; int[] newArr = new int[arr.length]; for (int i = 0; i < arr.length; i++) { if (arr[i] == 0) { newArr[last--] = arr[i]; } else { newArr[first++] = arr[i]; } } return newArr; } Moins

Since the order doesn't matter. Keep a separate pointer for your array. iterate through the array, for every 0 you find, swap it with the value at array[k], then increment k. This would be O(n) Otherwise, just sort it and return that. Which is O(nlogn) Moins

O(n) is the best conceivable time for this type of sort Here's one way to solve it: private static void moveZerosToRight(int[] a) { int rightIndex = a.length - 1; int leftIndex = 0; while (leftIndex < rightIndex) { if (a[rightIndex] == 0) rightIndex--; else { if (a[leftIndex] == 0) { swap(a, leftIndex, rightIndex); rightIndex--; } leftIndex++; } } } private static void swap(int[] a, int i, int j) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } Moins

Afficher Plus de réponses

1.Given a string, write a function that return if it is Palindrome. This wasn't asked directly but from interviewer example i was need to understand that this function must ignore all spaces and special symbols. 2. Given an array, write a function that return true if any 3 elements of this array can sum to 0. My first solution was the simplest and far from best which result in O(n^3). Then interviewer asked me to improve to improve it to O(n^2). This give me a hint that i can use Hash to reduce complexity.

13 réponses

As I wrote I used HashSet to store all values so I can for every pair of numbers check if there is negative one in HashSet istead of thrid for so overall complexity will be reduced to n+n^2 which is O(n^2) Moins

How do you know you are not using the same number twice? for example: {2,-1,0} you will sum 2+(-1)=1 and search in the hash for (-1) which you will find but you already used it. Moins

Ignore my previous answer, copy and paste issue. Time complexity is O(n^2) private static boolean hasThreeElementsSumUpToZero(int[] a) { HashMap cache = new HashMap(); for (int i : a) { if (cache.containsKey(i)) { cache.put(i, cache.get(i) + 1); } else cache.put(i, 1); } for (int i = 0; i 1) return true; } else if (cache.containsKey(target)) return true; } } return false; } Moins

Afficher Plus de réponses
Hidoc Dr

1.What is latest version of android and whats the new features for developer 2 .Difference bw paracables and serializable 3. what is build.gradle to switch bw fragment to activity 5. methods of adapter 6. what is request body parameter in network call 7. how we can do migration in room db

7 réponses

Pie (Android 9) API level-28 Upcoming Version Q (Android 10) API level-29

2.Ans In Android we cannot just pass objects to activities. To do this the objects must either implement Serializable or Parcelable interface. Serializable- Serializable is a standard Java interface. You can just implement Serializable interface and add override methods. The problem with this approach is that reflection is used and it is a slow process. This method creates a lot of temporary objects and causes quite a bit of garbage collection. However, Serializable interface is easier to implement. Parcelable- Parcelable process is much faster than Serializable. One of the reasons for this is that we are being explicit about the serialization process instead of using reflection to infer it. It also stands to reason that the code has been heavily optimized for this purpose. 1.Parcelable is faster than Serializable interface 2.Parcelable interface takes more time to implement compared to Serializable interface 3.Serializable interface is easier to implement 4.Serializable interface creates a lot of temporary objects and causes quite a bit of garbage collection 5`Parcelable array can be passed via Intent in android Moins

3.Ans. Gradle is a build system (open source) which is used to automate building, testing, deployment etc. “Build.gradle” are scripts where one can automate the tasks. Moins

Afficher Plus de réponses

Write a function that would calculate a Pascal triangle element, given its coordinates.

7 réponses

Generally Pascal's triangle is considered to be 0-indexed, as it is based on combinations. public long Pascal(long n, long r) { if (r > n || r n) return Pascal(n, n - r); if (r == 0) return 1; return n * Pascal(n - 1, r - 1) / r; } Moins

private static int nCalc(int n,int k){ return factorial(n) / (factorial(k) * factorial(n-k)); } private static int factorial(int f){ int retval = 1; for (int i=1;i<=f;i++){ retval*=i; } return retval; } Moins

public static void main(String[] args) { int r = 5; for (int i = 1 ; i <= r; i ++) { int c = 1; for (int j = 1; j <= i; j ++) { System.out.print(c); c = c * (i - j) / j; } System.out.println(); } } Moins

Afficher Plus de réponses

(this is a little easier to explain if it's drawn out, but I'll try my best to do it here) Given some integer N = 2^k which represents an NxN matrix, write a function that fills the matrix with 'L' shapes, such that the entire matrix is filled except for 1 empty space. For example, a 2x2 matrix would have 3 spaces filled with one of the corners empty. And a 4x4 matrix would have the entire outer row of spaces filled, with the center 4 filled the same way the 2x2 matrix is filled.

4 réponses

No. The smallest thing you're allowed to enter into the graph is an L shape. Forget about the fact that the L shapes filling the graph are represented by bits, because you aren't allowed to fill it in that manner. Also keep in mind that only 30 minutes was given to solve the problem. Moins

Do you know in how many days they give the result if one goes through all rounds? Moins

Less than a week I believe

Afficher Plus de réponses
Mantra Labs

Since i have a working experience of 1 year and 3 months, i was told to join as a Fresher, because i haven't worked professional working experience in Android Development. And for a fresher, salary is quite less as you can expect. But at the end of the day, you are getting paid while you are at learning stage. Should be enough for a fresher only.

5 réponses

Dude, When you will join them they will say work free for next three month and buy mac book. I think that was one of worst company I worked in my career. Rest is your decision. You can get better job, than this. Parag will tell after one month that "I am not here to full fill my promise". Moins

Is it true that one has to buy a MAC with their own money, otherwise considered unworthy? Also, how much is the pay for a fresher? Moins

Considering that the Android development is a growing field, i wanted to work on it as a professional FTE. And for that, i compromised with my salary package. Moins

Afficher Plus de réponses

Typical Android Layouts (What's the best way to lay element vertically etc.). Android Lifecycle. LinkedList vs Arrays.

4 réponses

Yes, the answer is (obviously) a Vertical LinearLayout. I had a bit of a brain fart and called it a Linear ListView, which is incorrect. Moins

Hello Michael, Have you been in a FB's interview before?

Hi, Yes, I'm the original poster - I got the phone screen but did not go to the next round unfortunately. Moins

Afficher Plus de réponses

Your photo-sharing app displays a system notification when the user receives a photo. Your app should display the photo when the user taps the notification. Which of the following do you need to attach to the Notification object that you pass to NotificationManager? A. An Activity reference B. A PendingIntent C. A BroadcastReceiver D. A Fragment transaction

5 réponses

A.Pending Intent

B. A Pending Intent

Pending Intent is the answer, Please Confirm

Afficher Plus de réponses
Uvionics Tech

Why are you jumping from the previous company?

4 réponses

Too much work pressure and I have to work during all of the Sundays in the calendar. No leaves from the company itself and even in the case of a leave, they'll cut our pay. So I'm looking for a much better company. Moins

Thank you for sharing your wonderful experience.Infact I think you would be the first person complaining about your own current working company to an interviewer which openly reveals your attitude..As far as my knowledge if you do not have a nice attitude towards your company whatever your company’s approach towards you, you will not be hired anywhere.Try this next time.I have had a nice experience with them.Anyway thanks for sharing the info. Moins

I got a job elsewhere with much better pay and management. So no issues

Afficher Plus de réponses

Create an app fetching car details from a server and showing them in a list. Then localize hem in a google map. Also showing all the cars in the map as pins

4 réponses

Project created

How you created the app? What sort of ui and code organisation you adopted that satisfied mytaxi team ? I did created the app with was functional as per their requirements but certainly that was not what they are looking for please let us know Moins

Did you use unit tests in your code?

Afficher Plus de réponses
1 - 10 sur 5 909 Questions d'entretien