Explaining here , How Gradle LifeCycle Works during build phase:

1.) Initialization Phase (Setting.gradle file) -> All Projects are listed in this file since it is required to make new Instance for every module Project so that Gradle can make queue to run build.gradle …


Given an array of positive numbers, where each element represents the max number of jumps that can be made forward from that element, write a program to find the minimum number of jumps needed to reach the end of the array (starting from the first element). If an element is 0, then we cannot move through that element.

package practice;

public class ArrayJump {

public int countMinJumps(int[] jumps) {

if (jumps == null || jumps.length < 2) {
return 0;
}
int[] minJumps = new int[jumps.length];
minJumps[0] = 0;
for (int i = 1; i < minJumps.length; i++) {…

I am writing the basic cache technique here to make it faster, Thread Safe, and with cache Expiry Support.

Component used:

  1. LinkedHashMap

a.) For saving Entry in map to get value in O(1)

b.) To remove oldest entry from Cache map if size exceeds from a limit with accessOrder property…


class Solution {
public List<String> generateParenthesis(int n) {
List<String> output = new ArrayList<String>();
if(n == 0){
return output…

When to use WorkManager:

1.) If Task is defferable , repeated with no exact time, Need to be completed sure even on Reboot, Then use WorkManager.

2.) If any work is triggered online, use Push Notification to trigger WorkManager Work.

3.) If you want to send Data instantly from Mobile…


In this post , I just want to give basic understanding for those who just started the memory Profiling to optimise memory for Android.

Android kernel was first developed it and it was based on Linux-Kernel. …


public static String[] ternaryTreePaths(Node root) {
if(root== null ) return null;
ArrayList<String> al = new ArrayList<String>();
ArrayList<String> res = new ArrayList<String>();
dfs(root, al, res);
return res.toArray(new String[res.size()]);
}

public static void dfs(Node root, ArrayList<String> list, ArrayList<String> res){…

class Solution {

//Handling if isFirstNodeFound and isSecondNodeFound is found to avoid //stack recursion processing unnecessarily if LCA is found.

static boolean isFirstNodeFound = false;

static boolean isSecondNodeFound = false;

public static Node lca(Node root, Node node1, Node node2) {

if(root == null) return null;

//Handling if any of target…


Given an array of size n, find the majority element. The majority element is the element that appears more than floor(n/2) times.

You may assume that the array is non-empty and the majority element always exist in the array.

Example :

Input : [2, 1, 2]
Return : 2 which occurs 2 times which is greater than 3/2.

public class Solution {
// DO NOT MODIFY THE LIST. IT IS READ ONLY
public int majorityElement(final List<Integer> A) {
int ans = A.get(0);
int counter = 1;
for(int i=1; i<A.size(); i++){
if(counter ==0){
ans = A.get(i);
counter++;
continue;
}
if(ans == A.get(i)){
counter++;
}else{
counter — ;
}

}
return ans;
}
}

Amit Gupta

Principal Software Engineer , Mobile Engineering

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store