We can easily solve this problem in linear time by using hashing. The idea is to use a set to check if a subarray with zero-sum is present in the given array or not. Traverse the array and maintain the sum of elements seen so far. If the sum is seen before (i.e., the sum exists in the set), return true as there exists at least one subarray with zero-sum that ends at the current index; otherwise, insert the sum into the set.
#Data_structure
#Source_code
#Data_structure
#Source_code
Java
We can easily solve this problem in linear time by using hashing. The idea is to use a set to check if a subarray with zero-sum is present in the given array or not. Traverse the array and maintain the sum of elements seen so far. If the sum is seen before…
The time complexity of the above solution is O(n) and requires O(n) extra space, where n is the size of the input.
#Data_Structure
#Output
#Data_Structure
#Output
Media is too big
VIEW IN TELEGRAM
Java Virtual Threads
Concurrent applications, those serving multiple independent application actions simultaneously, are the bread and butter of Java serving-side programming. The thread has been Java's Primary unit of concurrency since its inception and is core to the entire Java platform. However, it can no longer efficiency represent a domain unit of concurrency. As a result, Java has seen a proliferation of libraries and frameworks that offer scalability while abandoning the thread as the unit of software concurrency - and, with it, the support of Java's observability tooling. In this session, learn how Project Loom aims to reinstate the thread as an efficient unit of concurrency by adding a lightweight implementation of threads of the Java platform.
Concurrent applications, those serving multiple independent application actions simultaneously, are the bread and butter of Java serving-side programming. The thread has been Java's Primary unit of concurrency since its inception and is core to the entire Java platform. However, it can no longer efficiency represent a domain unit of concurrency. As a result, Java has seen a proliferation of libraries and frameworks that offer scalability while abandoning the thread as the unit of software concurrency - and, with it, the support of Java's observability tooling. In this session, learn how Project Loom aims to reinstate the thread as an efficient unit of concurrency by adding a lightweight implementation of threads of the Java platform.
Print Program in Java (Another way)
You can also use a method where number or string is not predefined. Here, user has to put the number or string as input to check if the number/string is palindrome.
Palindrome number algorithm
* Get the number to check for palindrome
* Hold the number in temporary variable
* Reverse the number
* Compare the temporary number with reversed number
* If both numbers are same, print "palindrome number"
* Else Print "not palindrome"
#Source_code
#13
You can also use a method where number or string is not predefined. Here, user has to put the number or string as input to check if the number/string is palindrome.
Palindrome number algorithm
* Get the number to check for palindrome
* Hold the number in temporary variable
* Reverse the number
* Compare the temporary number with reversed number
* If both numbers are same, print "palindrome number"
* Else Print "not palindrome"
#Source_code
#13
Factorial Program using loop in java
Let's see the factorial Program using loop in Java.
#Source_code
#14
Let's see the factorial Program using loop in Java.
#Source_code
#14
Print all subarrays with 0 sum
Google Translate Icon
Given an integer array, print all subarrays with zero-sum.
Note that the problem deals with subarrays that are contiguous, i.e., whose elements occupy consecutive positions in the array.
#Data_Structure
Google Translate Icon
Given an integer array, print all subarrays with zero-sum.
Note that the problem deals with subarrays that are contiguous, i.e., whose elements occupy consecutive positions in the array.
#Data_Structure
Java
Print all subarrays with 0 sum Google Translate Icon Given an integer array, print all subarrays with zero-sum. Note that the problem deals with subarrays that are contiguous, i.e., whose elements occupy consecutive positions in the array. #Data_Structure
Using Brute-Force
A naive solution is to consider all subarrays and find their sum. If the subarray sum is equal to 0, print it. The time complexity of the naive solution is O(n3) as there are n2 subarrays in an array of size n, and it takes O(n) time to find the sum of its elements. We can optimize the method to run in O(n2) time by calculating the subarray sum in constant time.
#Source_code
#Data_structure
A naive solution is to consider all subarrays and find their sum. If the subarray sum is equal to 0, print it. The time complexity of the naive solution is O(n3) as there are n2 subarrays in an array of size n, and it takes O(n) time to find the sum of its elements. We can optimize the method to run in O(n2) time by calculating the subarray sum in constant time.
#Source_code
#Data_structure
Media is too big
VIEW IN TELEGRAM
Java 20 What's new in JDK 20 ?
With Oracle ongoing six-month release cadence and critical path updates, Java continues to thrive due to the core it is built upon: Trust, Innovation, and Predictability. JDK 20, the latest release of the java SE Platform, continues improving on the preview and incubator features unveiled in earlier versions. The new release includes improvement to the Java language and libraries, as well as updates to the Java concurrency model being developed via Project Loom.
With Oracle ongoing six-month release cadence and critical path updates, Java continues to thrive due to the core it is built upon: Trust, Innovation, and Predictability. JDK 20, the latest release of the java SE Platform, continues improving on the preview and incubator features unveiled in earlier versions. The new release includes improvement to the Java language and libraries, as well as updates to the Java concurrency model being developed via Project Loom.
Factorial Program using recursion in java
Let's see the factorial program in java using recursion.
#Source_code
#15
Let's see the factorial program in java using recursion.
#Source_code
#15
Armstrong Number Java Program
The following Java program prints all the Armstrong numbers up to the specified limit.
Armstrong Number in Java
in this section, we will discuss what is Armstrong number and also create Java programs to check if the given number is an Armstrong number or not. The Armstrong number program frequently asked in java coding interviews and academics.
#Source_coude
#16
The following Java program prints all the Armstrong numbers up to the specified limit.
Armstrong Number in Java
in this section, we will discuss what is Armstrong number and also create Java programs to check if the given number is an Armstrong number or not. The Armstrong number program frequently asked in java coding interviews and academics.
#Source_coude
#16
Let's create another java program that checks if the number is an Armstrong number or not,
Armstrong Number
An Armstrong number is a positive m-digit number that is equal to the sum of the mth power of their digits. It is also known as pluperfect, or Plus Perfect, or Narcissistic number. It is an OEIS sequence A005188. Let's understand it through an example.
#Source_code
#17
Armstrong Number
An Armstrong number is a positive m-digit number that is equal to the sum of the mth power of their digits. It is also known as pluperfect, or Plus Perfect, or Narcissistic number. It is an OEIS sequence A005188. Let's understand it through an example.
#Source_code
#17
Media is too big
VIEW IN TELEGRAM
Z Garbage Collector: The next Generation
The Z Garbage Collector (ZGC) - a scale, low-latency garbage collector providing sub-millisecond max pause times-continues to evolve. This session will review the design goals behind ZGC and provide a look into the impact of the upcoming support for multiple generations. It will also present general guidance on selecting a garbage collector given use case characteristics.
The Z Garbage Collector (ZGC) - a scale, low-latency garbage collector providing sub-millisecond max pause times-continues to evolve. This session will review the design goals behind ZGC and provide a look into the impact of the upcoming support for multiple generations. It will also present general guidance on selecting a garbage collector given use case characteristics.