Solved below leet code problem using Java 8 Streams.
https://leetcode.com/problems/merge-sorted-array/
Solution:
class Solution {
public void merge(int[] nums1, int m, int[] nums2, int n) {
int[] nums3 = Arrays.copyOf(nums1,m);
int[] nums4 = Arrays.copyOf(nums2,n);
Stream<int[]> stream1 =Stream.of(nums3);
Stream<int[]> stream2 =Stream.of(nums4);
Stream<int[]> resultingStream = Stream.concat(stream1, stream2);
int[] nums5 = resultingStream.flatMapToInt(y -> Arrays.stream(y)).sorted().toArray();
for(int i=0;i<nums5.length;i++){
nums1[i] = nums5[i];
}
}
}
In this blog using the Spring WebFlux module, we are going to leverage the functional…
Spring Cloud Function is a project within the Spring ecosystem that allows developers to build…
RabbitMQ is an open-source message broker software that implements the Advanced Message Queuing Protocol (AMQP).…
Spring Integration is a powerful extension of the Spring Framework designed to support the implementation…
The Spring Cloud Config Client is a component of the Spring Cloud framework that enables…
In Python, handling CSV (Comma Separated Values) files is easy using the built-in csv module.…