This following post is based on the Udemy Course: Java Multithreading In the following code, the result of sysout(count) will be 0. This is because, even though we have started the two threads t...
Java Multithreading - Basic Thread Synchronization
This following post is based on the Udemy Course: Java Multithreading When data is shared between multiple threads, a common issue arises with data caching. In the following example, there is a ...
Java Multithreading - Starting Java Threads
This following post is based on the Udemy Course: Java Multithreading We can create threads either by extending the Thread class or by implementing the Runnable interface. Here is an example of ...
Delete one
PROBLEM DESCRIPTION Given an integer array A of size N. You have to delete one element such that the GCD(Greatest common divisor) of the remaining array is maximum. Find the maximum value of GCD. ...
Find Greatest Common Divisor of Array
PROBLEM DESCRIPTION Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums. The greatest common divisor of two numbers is the largest pos...
GCD and Inverse Modulo (Theory)
Inverse Modulo GCD
Count pairs in array divisible by K
PROBLEM DESCRIPTION You are given a number N. Find the total number of setbits in the numbers from 1 to N. geeksforgeeks SOLUTION class Solution { public static long countKdivPairs(int nu...
Count Total Set Bits Till N
PROBLEM DESCRIPTION You are given a number N. Find the total number of setbits in the numbers from 1 to N. geeksforgeeks SOLUTION class Solution{ static int countBits(int A){ //...
Minimum Swaps required to group all 1s together
PROBLEM DESCRIPTION Given an array of 0s and 1s, we need to write a program to find the minimum number of swaps required to group all 1s present in the array together. geeksforgeeks SOLUTION cl...
All Sub-Matrices Sum
PROBLEM DESCRIPTION Given a NxM 2-D matrix, the task to find the sum of all the submatrices. geeksforgeeks SOLUTION import java.io.*; class GFG { public static int matrixSum(int[][] matri...