↳
We can use a HashMap for it where name will be the key and phone number will be the value. If second time any name appears then its key will be already present in the map and it will be deleted. Less
↳
Name can be same. A contact will be duplicated only if phone number is same. Need to use number as key. Less
↳
Instead of map you can use set
↳
Rewrote the entire project.
↳
Rewrote the entire project+1
↳
The key in these questions is to cover the fundamentals, and be ready for the back-and-forth with the interviewer. Might be worth doing a mock interview with one of the Agoda or ex-Agoda Senior Android Developer experts on Prepfully? They give real-world practice and guidance, which is pretty helpful. prepfully.com/practice-interviews Less
↳
haven't checked leetcode, but how about this? firstly use (int)(Math.log10(number) + 1) to get the number of digits in the given number. (Note: you have to handle 0 differently) e.g 16138832 should return 8. Use this number of digits to get an idea of digit place's spelling (billion, million, thousand, hundred) Then for each digit (0~9) I'm thinking of using the previous answer's suggestion of HashMap to get the spelling. So I imagine there would be two HashMaps, one for getting the digit spelling (one, two, ... nine, ten, ... , nineteen), the other for the digit place spelling (billion, million, thousand, hundred, ... thirty, twenty) Less
↳
Here is the answer. Sorry for the extra spaces :) private static String spellNumber(String number) { HashMap level1Num = new HashMap(); level1Num.put(1, " one "); level1Num.put(2, " two "); level1Num.put(3, " three "); level1Num.put(4, " four "); level1Num.put(5, " five "); level1Num.put(6, " six "); level1Num.put(7, " seven "); level1Num.put(8, " eight "); level1Num.put(9, " nine "); level1Num.put(10, " ten "); level1Num.put(11, " eleven "); level1Num.put(12, " twelve "); level1Num.put(13, " thirteen "); level1Num.put(14, " fourteen "); level1Num.put(15, " fifteen "); level1Num.put(16, " sixteen "); level1Num.put(17, " seventeen "); level1Num.put(18, " eighteen "); level1Num.put(19, " ninteen "); HashMap level2Num = new HashMap(); level2Num.put(2, " twenty "); level2Num.put(3, " thirty "); level2Num.put(4, " fourty "); level2Num.put(5, " fifty "); level2Num.put(6, " sixty "); level2Num.put(7, " seventy "); level2Num.put(8, " eighty "); level2Num.put(9, " ninty "); String output = ""; while (number.length() > 0) { String block; if (number.length() % 3 == 0) { block = number.substring(0, 3); } else { block = number.substring(0, (number.length() % 3)); } if (block.length() > 2) { output += level1Num.get(Integer.parseInt(block.substring(0, 1))) + " hundred "; number = number.replace(block.subSequence(0, 1), ""); block = block.replace(block.subSequence(0, 1), ""); } int block2 = Integer.parseInt(block); if (block2 = 7 && number.length() = 4 && number.length() <= 6) { output += " thousand"; } number = number.replace(block, ""); } return output; } Less
↳
It was hard to write under pressure. Basically, I was using HashMap. Key for integer, value for spelling. Solution you can find somewhere at leetcode Less
↳
I answered we can make a generic class for errors which can be used throughout the app. They wanted a specific name. They then answered that we can use GlobalErrorScope for it. It doesn't make sense. You can name it anything internally. Less
↳
Create Kotlin Sealed class that can be used as enum for handling different status Less
↳
There's quite an extended back and forth in actual interviews for questions like this, so nothing quite like real practice. The Prepfully Gojek Senior Android Developer experts have actually worked in this role, so they're able to do an honest-to-God accurate mock, which really puts you through the paces. prepfully.com/practice-interviews Less
↳
The candidate is expected to write production-quality code in 1.5h live coding round- pagination, dagger/HILT, unit testing, RecyclerView, Clean architecture, and MVVM. No margin for any error allowed. The panel usually consists of petty android developers who completely ignore the time constraint and interview environment. They love playing with their few minutes of power. Less
↳
Nothing.
↳
Activity Lifecycle Methods onCreate() Called when activity first created onRestart() Called after activity stopped, prior to restarting onStart() Called when activity is becoming visible to user onResume() Called when activity starts interacting with user onPause() Called when a previous activity is about to resume onStop() Called when activity no longer visible to user onDestroy() Final call received before activity is destroyed ----------------- Creational patterns: Builder (e.g. AlertDialog.Builder) Dependency Injection (e.g. Dagger 2) Singleton Structural patterns: Adapter (e.g. RecyclerView.Adapter) Facade (e.g. Retrofit) Behavioral patterns: Command (e.g. EventBus) Observer (e.g. RxAndroid) Model View Controller Model View ViewModel (similar to the MVC pattern above) Less
↳
Handler
↳
It depends , you can use AsyncTask as well.
↳
Assuming the array is sorted. class myCode { public static void main (String[] args) throws java.lang.Exception { int a[] = {1,3,5,7,9}; int b[] = {-1, 0,2,4,6,7,8,9,10}; int c[] = new int[a.length+b.length]; if (b[0] > a[a.length-1]) { // Merge array b to a in O(n) times } else { int i = 0; int j = 0; int k = 0; while (i < a.length) { if (a[i] <= b[j]) { c[k++] = a[i++]; } else if (b[j] <= a[i]) { c[k++] = b[j++]; } else { c[k++] = a[i++]; c[k++] = b[j++]; } } while (j < b.length) { c[k++] = b[j++]; } } for (int i = 0 ; i < c.length; i++) { System.out.println(c[i]); } } } Less
↳
static void mergeAndPrint(int[] one, int[] two) { int[] result = new int[one.length + two.length]; int oneIndex = 0, twoIndex = 0; for (int i = 0; i = one.length) { result[i] = two[twoIndex]; twoIndex++; } else if (twoIndex >= two.length) { result[i] = one[oneIndex]; oneIndex++; } else { int o = one[oneIndex]; int t = two[twoIndex]; if (o <= t) { result[i] = o; oneIndex++; } else { result[i] = t; twoIndex++; } } } System.out.println(Arrays.toString(result)); } Less
↳
Resuming... DI is a technique whereby one object supplies the dependencies of another object. Dagger 2 is the well know compile-time framework for dependency injection in Android. Less
↳
DI is a technique whereby one object supplies the dependencies of another object. Dagger 2 is the well know compile-time framework for dependency injection in Android. Less