Java Deque (Finding the max number of unique integers from subarrays.) - java

I was trying to solve a HackerRank problem on Java Deque. My code passed all the cases apart from the ones which have 100,000 inputs.
Problem: In this problem, you are given N integers. You need to find the maximum number of unique integers among all the possible contiguous subarrays of size M.
--->So we wre given N integers, and need to find the number of "unique integers" in each contagious subarray(of size M). And then print the maximum number of those "unique Integers".
link: https://www.hackerrank.com/challenges/java-dequeue/problem
My Code:
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Deque deque = new ArrayDeque<>();
HashSet<Integer> set = new HashSet<>();
int n = in.nextInt();
int m = in.nextInt();
int max=0;
for (int i = 0; i < n; i++) {
int num = in.nextInt();
deque.add(num);
set.add(num);
if(i>=m-1){
if(set.size()>max)max=set.size();
Integer removed=(Integer)deque.removeFirst();
set.remove(removed);
set.add((Integer)deque.peek());
}
}
System.out.println(max);
}
Please tell me where my code went wrong.

What is the point of this line?
set.add((Integer)deque.peek());
I don't see anything in your code that is slow. I just wonder how you can keep track of unique numbers by using a set, given that a set only tells you if there is such a number (but not how many occurrences of the same number there are). And you don't want to keep scanning the deque to see if the number being removed is the last one.
I don't think this is great/fast code, but it seems to pass the test-cases. I keep a count of how many of each integer there is in the window by using a map (and use some of your code).
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Deque<Integer> deque = new ArrayDeque<>();
HashMap<Integer, Integer> counts = new HashMap<>();
int n = in.nextInt();
int m = in.nextInt();
int max = 0;
for (int i = 0; i < n; i++) {
int num = in.nextInt();
deque.add(num);
int count = counts.getOrDefault(num, 0);
counts.put(num, ++count);
if (i >= m - 1) {
if (counts.size() > max) max = counts.size();
Integer removed = deque.removeFirst();
int removing = counts.get(removed);
removing--;
if (removing == 0) {
counts.remove(removed);
} else {
counts.put(removed, removing);
}
}
}
System.out.println(max);
}
}

Just wanted to share how I solved it in case it helps.
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Deque deque = new ArrayDeque();
Set<Integer> integers = new HashSet<>();
int n = in.nextInt();
int m = in.nextInt();
long result = 0;
for (int i = 0; i < n; i++) {
int num = in.nextInt();
deque.add(num);
integers.add(num);
if (deque.size() == m) {
long currentSize = integers.size();
if (currentSize > result) {
result = currentSize;
}
Integer removed = (Integer) deque.pollFirst();
if (!deque.contains(removed)) {
integers.remove(removed);
}
}
}
System.out.println(result);
}

We can optimize the space a little bit by avoiding the hashmap all together, but it seems like Hackerrank does not care about that. Any how I am putting my solution here which can solve this problem by using using a map.
private int countUniqueNumsInSubarrays(int[] nums, int m) {
Deque<Integer> deque = new LinkedList<>();
int maxUniqueCount = 0;
for (int i = 0; i < nums.length; i++) {
// if deque's left entry is outside the window then pop it out
while (!deque.isEmpty() && i - deque.peekFirst() >= m) {
deque.removeFirst();
}
// this will make sure that the deque only contains unique numbers,
// this is essentially helps us avoid that extra hash map
while (!deque.isEmpty() && nums[deque.peekLast()] == nums[i]) {
deque.removeLast();
}
deque.addLast(i);
if (i >= m - 1) {
maxUniqueCount = Math.max(maxUniqueCount, deque.size());
}
}
return maxUniqueCount;
}

import java.io.*;
import java.util.*;
import java.util.stream.Stream;
public class Solution {
public static void main(String[] args) {
var sc = new Scanner(System.in);
var split = sc.nextLine().split(" ");
int n = Integer.parseInt(split[0]);
int m = Integer.parseInt(split[1]);
if (!(1 <= n && n <= 100_000)) {
System.exit(0);
}
if (!(1 <= m && m <= 100_000)) {
System.exit(0);
}
if (!(m <= n)) {
System.exit(0);
}
split = sc.nextLine().split(" ");
sc.close();
int maxNumUniqueInt = 0;
HashSet<Integer> dist = new HashSet<>();
Deque<Integer> deque = new ArrayDeque<>();
int[] arr = Stream.of(split).mapToInt(Integer::parseInt).toArray();
for (int i = 0; i < m; i++) {
deque.addLast(arr[i]);
dist.add(arr[i]);
}
int num = dist.size();
if (maxNumUniqueInt < num) {
maxNumUniqueInt = num;
}
for (int i = m; i < n; i++) {
deque.addLast(arr[i]);
dist.add(arr[i]);
int remove = deque.removeFirst();
if (!deque.contains(remove)) {
dist.remove(remove);
}
num = dist.size();
if (maxNumUniqueInt < num) {
maxNumUniqueInt = num;
}
// System.out.println(i + " | " + deque + " | " + dist + " | " + maxNumUniqueInt);
}
System.out.println(maxNumUniqueInt);
}
}

import java.util.*;
public class test {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Deque<Integer> deque = new ArrayDeque<>();
int n = in.nextInt();
int m = in.nextInt();
int maxUnique = 0;
Map<Integer, Boolean> uniqSet = new HashMap<>();
for (int i = 0; i < n; i++) {
int num = in.nextInt();
deque.addLast(num);
uniqSet.put(num, true);
if(deque.size() == m){
// int uniqueSize = new HashSet<>(deque).size();
int uniqueSize = uniqSet.size();
maxUnique = Math.max(maxUnique, uniqueSize);
int x = deque.removeFirst();
if(!deque.contains(x)){
uniqSet.remove(x);
}
}
}
in.close();
System.out.println(maxUnique);
}
}

Related

Given an integer N. What is the smallest integer greater than N in java

I was trying to write a code that takes an integer between 1 and 1_000_000 and gives back the smallest integer greater than that with the same digits, and if it doesn't exist, it prints 0.
For example
input: 156
output 165
input 330
output 0
input 27711
output 71127
My problem is, my code below doesn't return the correct output for other inputs.
For example, in input 4231, the output should be 4312.
I'm having trouble finding the best algorithm that returns the correct output for every input.
tnx in advance
import java.util.Scanner;
public class Test4 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String x = sc.nextLine();
char[] chars = new char[x.length()];
char[] oldChars = new char[x.length()];
char temp;
for (int i = 0; i < x.length(); i++) {
chars[i] = x.charAt(i);
oldChars[i] = chars[i];
}
if (x.length() > 3){
for (int j = 0; j < x.length(); j++) {
if (chars[0] < chars[j]) {
temp = chars[0];
chars[0] = chars[j];
chars[j] = temp;
break;
}
}
for (int j = 1; j <= x.length() ; j++) {
for (int i = 1; i < x.length() - 1; i++) {
if (chars[i] > chars[i+1]){
temp = chars[i];
chars[i] = chars[i+1];
chars[i+1] = temp;
}
}
}
for (int i = 0; i < x.length(); i++) {
System.out.print(chars[i]);
}
}
else if (x.length() == 1)
System.out.println(0);
else {
temp = chars[x.length()-2];
chars[x.length()-2] = chars[x.length()-1];
chars[x.length()-1] = temp;
if (chars[x.length()-2] > oldChars[x.length()-2])
for (int i = 0; i < x.length(); i++) {
System.out.print(chars[i]);
}
else
System.out.println(0);
}
sc.close();
}
}
Try this, please
int muldigits(int n){
int result = 0;
String [] strings = String.valueOf(Math.abs(n)).split("(?!^)");
List<Integer> intsList = new ArrayList<>();
for (String string : strings) {
intsList.add(Integer.parseInt(string));
}
if(n<0){
Collections.sort(intsList);
String temp = Arrays.toString(intsList.toArray()).replace(", ", "");
System.out.println(temp);
result = - Integer.parseInt(temp.substring(1, temp.length()-1));
}else{
Collections.sort(intsList, Collections.reverseOrder());
String temp = Arrays.toString(intsList.toArray()).replace(", ", "");
result = Integer.parseInt(temp.substring(1, temp.length()-1));
}
return result;
}
Here is one approach.
Starting with the least N significant digits. N starts with 2. Save a copy.
then create all permutations of those N digits.
join them into a String and put in a TreeMap<String>
if there exists a next higher value of the original N digits, return the new value
with the new ending concatenated to the original.
else, increase N by one and repeat the process.
public class NextLargestInteger {
public static void main(String[] args) {
Generate 10 random numbers.
Random r = new Random();
for (int i = 0; i < 10; i++) {
int val = r.nextInt(Integer.MAX_VALUE);
System.out.printf("%-12s %-12s%n",val,nextHighest(Integer.toString(val)));
}
Prints something like
1446553155 1446553[515]
1801279982 18012[82799]
1894877459 18948774[95]
805018669 8050186[96]
521703779 5217037[97]
1926164416 19261644[61]
1236907656 12369076[65]
1326860288 1326860[828]
1049149602 10491496[20]
1516995584 1516995[845]
The brackets on the right show what endings were permuted to get the minimum
The primary method.
public static String nextHighest(String e) {
char[] digits = e.toCharArray();
// start two digits from the end
int i = digits.length - 2;
// tree set to store the permuted strings
NavigableSet<String> set = new TreeSet<>();
for (; i >= 0; i--) {
// the last N digits
char[] shortList =
Arrays.copyOfRange(digits, i, digits.length);
// save a copy of the original N digit ending
String originalTail = new String(shortList);
permute(shortList, digits.length - i, set);
// get the next higher ending from the set
String minTail = set.higher(originalTail);
// if it exists, return the value.
if (minTail != null) {
String head =
new String(Arrays.copyOfRange(digits, 0, i));
return String.format("%s[%s]", head, minTail);
}
// clear the set and try a larger ending.
set.clear();
}
// no success, return the original value.
return e;
}
Utility method to permute the character array
public static void permute(char[] elements, int length,
Set<String> vals) {
if (length == 1) {
vals.add(new String(elements));
} else {
for (int i = 0; i < length; i++) {
permute(elements, length - 1, vals);
if (length % 2 == 1) {
swap(elements, 1, length - 1);
} else {
swap(elements, i, length - 1);
}
}
}
}
Utility method to swap array elements.
public static void swap(char[] list, int i, int j) {
char temp = list[i];
list[i] = list[j];
list[j] = temp;
}
}
If you can use apache commons collections4 and performance does not matter you can use something like that:
package test;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.stream.Collectors;
public class NextNumberCalculator {
public int calculateNearest(int input) {
List<Character> inputChars = String.valueOf(input).chars()
.mapToObj(c -> (char) c)
.collect(Collectors.toList());
return CollectionUtils.permutations(inputChars)
.stream()
.mapToInt(chars -> Integer.parseInt(StringUtils.join(chars, "")))
.filter(permutation -> permutation > input)
.min()
.orElse(0);
}
}
Here some unit test:
package test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class NextNumberCalculatorTest {
private NextNumberCalculator calculator;
#BeforeEach
void setUp() {
calculator = new NextNumberCalculator();
}
#Test
void calculateNearest() {
Assertions.assertEquals(165, calculator.calculateNearest(156));
Assertions.assertEquals(0, calculator.calculateNearest(330));
Assertions.assertEquals(71127, calculator.calculateNearest(27711));
Assertions.assertEquals(414, calculator.calculateNearest(144));
}
}

Max of a list of strings in Java

I have data in the form of
String[] values = {"4,8", "1,6", "7,8", "1,5"}
where I have to find the max of the second element and if there are more than two of the max ("4,8" and "7,8"), find the one with the min of the first. So the output of values should be a string "4,8"
I am new to JAVA and I am not sure how exactly to go about this. I tried to use string split and something like
int[] num = new int[values.length];
int[] num2 = new int[values.length];
for (int i = 0; i<values.length; i++){
String[] test = values[i].split(",");
int nummed = Integer.parseInt(test[0]);
int nummed2 = Integer.parseInt(test[1]);
num[i] = nummed;
num2[i] = nummed2;
//System.out.println(test[0]);
//System.out.println(test[1]);
}
but it is quickly becoming very complicated and I would need to know the index or maybe filter out data to find the min of the first item.
This should be enough
class Main {
public static void main(String args[]) {
String[] values = {"4,8", "1,6", "7,8", "1,5"}; // try {"4,8", "1,6", "7,8", "1,5", "1,9"}
int right = Integer.MIN_VALUE;
int left = Integer.MAX_VALUE;
for (int i = 0; i<values.length; i++){
String[] test = values[i].split(",");
int nummed = Integer.parseInt(test[0]);
int nummed2 = Integer.parseInt(test[1]);
if (nummed2 >= right) {
if (right != nummed2) {
left = Integer.MAX_VALUE;
}
right = nummed2;
if (nummed < left) {
left = nummed;
}
}
}
System.out.println(left + "," + right);
}
}
public class StringManipulation {
public static void main(String args[]) {
System.out.println(output());
}
private static String output() {
String[] values = {"4,8", "1,6", "7,8", "1,5"};
int max = Integer.MIN_VALUE;
int first = Integer.MAX_VALUE;
for(int i = 0; i < values.length; i++) {
String[] arr = values[i].split(",");
if(Integer.parseInt(arr[1]) >= max){
max = Integer.parseInt(arr[1]);
first = Integer.parseInt(arr[0]) < first ? Integer.parseInt(arr[0]):first;
}
}
return (first) + "," + (max);
}
}
There could be multiple approaches to this problem. Given my understanding of the question, this is one of the simplest solutions.
Here's a solution that makes use of the fluent Comparator api, stream api and BigDecimals:
String[] values = {"4,8", "1,6", "7,8", "1,5"};
// create a custom comparator
Comparator<BigDecimal> comparator = Comparator
// first, comparing only the right side - the remainders
.comparing((BigDecimal num) -> num.remainder(BigDecimal.ONE))
// then, comparing the left side - the decimal part
.thenComparing(num -> num.setScale(0, RoundingMode.DOWN));
// find the max value using java stream api
Arrays.stream(values)
// replace commas with dots
.map(num -> num.replace(',', '.'))
// map values to bigdecimal
.map(BigDecimal::new)
// find the max element by our custom comparator
.max(comparator)
// print if an element is found (if the array was not empty)
.ifPresent(System.out::println);
Continuing with your solution, Tested. Works as expected, It was hard to type it all on mobile though.
public static void main(String arg[])
{
String[] values = {"4,8", "1,6", "7,8", "1,5","2,8"};
int[] num = new int[values.length];
int[] num2 = new int[values.length];
for (int i = 0; i<values.length; i++){
String[] test = values[i].split(",");
int nummed = Integer.parseInt(test[0]);
int nummed2 = Integer.parseInt(test[1]);
num[i] = nummed;
num2[i] = nummed2;
//System.out.println(test[0]);
//System.out.println(test[1]);
}
int max=0;
int min=0;
for(int i=0;i<num2.length;i++)
{
if(num2[i]>max) {
max =num2[i];
min=num[i];
}
else if(num2[i]==max)
min = min>=num[i]?num[i]:min;
}
System.out.println(min+","+max);
}
}

How to solve error: type Integer is not visible

I have created an ArrayList but when I try to access an element in it, I keep getting the error type Integer is not visible. With a Scanner named in, I read input from a file and create an array, then an ArrayList:
int n = in.nextInt();
int[] curr = new int[n];
for (int i = 0; i < n; i++) {
curr[i] = in.nextInt();
}
ArrayList<Integer> order = new ArrayList<>();
for (int item: curr) order.add(item);
However, when I try to access elements in order by creating an int variable called idx and running order.get(idx), I keep getting the above error. How do I fix this?
Thanks,
Satya
You can try with this code:
private static Scanner in = new Scanner(System.in);
public static void main(String args[]) {
System.out.print("array length = ");
int n = in.nextInt();
int[] curr = new int[n];
for (int i = 0; i < n; i++) {
System.out.print("item"+i+" = ");
curr[i] = in.nextInt();
}
ArrayList<Integer> order = new ArrayList<>();
for (int item: curr) order.add(item);
System.out.print("idx = ");
int idx = in.nextInt();
if (idx<order.size()){
System.out.println(order.get(idx));
} else {
System.out.println("idm out of bounds...\n" +
"result with modulo length of list:");
System.out.println(order.get(idx%order.size()));
}
}
You can also try with this code.
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] curr = new int[n];
for (int i = 0; i < n; i++) {
curr[i] = in.nextInt();
}
ArrayList<Integer> order = new ArrayList<>();
for (int item : curr)
order.add(item);
int size = order.size();
while (true) {
System.out.print("index= ");
int idx = in.nextInt();
if (idx < size) {
System.out.println(order.get(idx));
break;
}
System.out.println("Error : indexOutofBoundException");
System.out.println("Try again!");
}
}

Java program to find the duplicate record in an array when the number is repeated more than twice

I am very new to java and a junior java developer.
The requirement asks to get the list of customerid and if the list contains customer ids which are repeated, then it would display the dupliate record. And if there are no customer id which are repeated then it would display no duplicate record. I have tried but stuck at the point where the customerid is repeated more than twice. My code works fine till the point the customerid is repeated twice.
For ex:
Customerid:(5 input)
123
123
234
123
234
Output(Expected)
123
234
Actual:
123
123
123
234
for Scenario where there is no duplicate element, it would print no records found.
Input:
123
234
345
456
567
Output:
No records found
Output of my code is wrong when the repetition is more than twice.
Kindly Advice.
Code:
package firstpack;
import java.util.Scanner;
public class Class9 {
public static void main(String[] args) {
int a, i;
Scanner sc = new Scanner(System.in);
a = sc.nextInt();
long[] b = new long[a];
for (i = 0; i <= (b.length - 1); ) {
do {
b[i] = sc.nextLong();
i++;
}
while (i <= a - 1);
}
System.out.println("Duplicate records :");
for (i = 0; i < b.length - 1; i++) {
for (int j = i + 1; j < b.length; j++) {
if ((b[i] == (b[j])) && (i != j)) {
System.out.println(b[j]);
}
}
}
}
//Try this code if you don't want to use set for Array uniqueness.
import java.util.*;
class MyUnique{
public static void main(String args[]){
Scanner sc= new Scanner(System.in);
ArrayList<Integer> arr= new ArrayList<Integer>();
int length=sc.nextInt();
int myarr[]= new int[length];
for(int i=0;i<length;i++){
System.out.println("enter the value of array");
int value=sc.nextInt();
if(arr.contains(value)){
System.out.println("dublicate value not add and index not increased");
i = i-1; //index will not increse
}else{
myarr[i] = value;
}
arr.add(value);
}
System.out.println("Here is the array output");
for(int m=0;m<length; m++){
System.out.print(myarr[m]+",");
}
}
}
As commented by alfasin, you should use HashSet as they don't take duplicate values. So you don't have to use any loops to check. After that just print the set and you will get the result. So use something like this :
Set<Integer> s = new HashSet<Integer>();
s.add(123);
s.add(123);
s.add(234);
s.add(123);
s.add(234);
for(Integer i : s) {
System.out.println(i);
}
When I print it I get:
234
123
Hope that helps !!
You can use LinkedHashSet to get the distinct list of inputs and counts how many same inputs are in the list.
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int inputCount = sc.nextInt();
List<Long> inputArr = new ArrayList<>();
for (int i = 0; i < inputCount; i++){
inputArr.add(sc.nextLong());
}
System.out.println("==================");
Set<Long> distinctArr = new LinkedHashSet<>(inputArr);
for (Long input : distinctArr) {
if(Collections.frequency(inputArr, input) > 1){
System.out.println(input);
}
}
}
Or you could just put your result in HashSet before print out.
Set<Long> set = new HashSet<Long>();
for (i = 0; i < b.length - 1; i++) {
for (int j = i + 1; j < b.length; j++) {
if ((b[i] == (b[j])) && (i != j)) {
set.add(b[j]);
}
}
}
for (Long result: set) {
System.out.println(result);
}
Try this use set to find out if duplicate entry exists or not
public static void main(String[] args) throws IOException {
int a, i;
Scanner sc = new Scanner(System.in);
a = sc.nextInt();
long[] b = new long[a];
for (i = 0; i <= (b.length - 1); ) {
do {
b[i] = sc.nextLong();
i++;
}
while (i <= a - 1);
}
Set<Long> first = new HashSet<>();
Set<Long> duplicates = new HashSet<>();
for (i = 0; i < b.length ; i++) {
if(!first.add(b[i])) {
duplicates.add(b[i]);
}
}
String message = duplicates.size() > 0 ? "Duplicate records:": "No Duplicate entry";
System.out.println(message);
duplicates.stream().forEach(System.out::println);
//in case if you want to print unique entries
first.removeAll(duplicates);
if(first.size() > 0){
System.out.println("Unique Entries:");
first.stream().forEach(System.out::println);
}
}
You can use HashMap to store the count of each element and print only if the count is more than 1. And if you need in the order of insertion then use LinkedHashMap instead of HashMap.
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Class9 {
public static void main(String[] args) {
int a, i;
Scanner sc = new Scanner(System.in);
a = sc.nextInt();
long[] b = new long[a];
Map<Long, Integer> countMap = new HashMap<Long, Integer>();
for (i = 0; i <= (b.length - 1); ) {
do {
b[i] = sc.nextLong();
if (countMap.containsKey(b[i])) {
countMap.put(b[i], countMap.get(b[i]) + 1);
} else {
countMap.put(b[i], 1);
}
i++;
}
while (i <= a - 1);
}
System.out.println("Duplicate records :");
for (Long key : countMap.keySet()) {
if (countMap.get(key) > 1) {
System.out.println(key);
}
}
}
}

Getting group of the same numbers numbers

I'm working on a code which will count how many are the groups with the same number.
For example:
11022 = 2 groups with the same number
1100021 = 2 groups with the same number
12123333 = 1 group with the same number
So far I've come up to this code:
package Numbers;
import java.util.*;
public class Numbers{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int strI ;
strI = scan.nextInt();
int[] a = {strI};
System.out.println(sum(a));
System.out.println("length = "+a.length);
}
public static in sum(int[] a){
int sum = 0;
int last = 0;
for (int i = 0; i < a.length - 1; i++){
if(a[i] == a[i + 1] && last != a[i + 1]){
sum++;
}
last = a[i];
}
return sum;
}
}
My problem is that the inputted number will register as 1 index. is it possible to enter a series of number that will go to different indexes?
This is easiest done by converting it to a string so you don't have to deal with place value. After all, you only care about the characters themselves.
public static void main(String[] args){
// Get number n... Assuming n has been set to the int in question
int n = ...; //Fill in with whatever int you want to test
String s = n + "";
char same = ' ';
int consec = 0;
for(int i = 0; i < s.length() - 1; i++){
if(s.charAt(i) == s.charAt(i+1)){
if(same == ' ')
consec++;
same = s.charAt(i);
}
else{
same = ' ';
}
}
System.out.println(consec);
}
First, you can get the count of consecutive digits with something like
public static int sum(int a) {
String strI = String.valueOf(a);
int count = 0;
boolean inRun = false;
for (int i = 1; i < strI.length(); i++) {
if (strI.charAt(i - 1) == strI.charAt(i)) {
if (inRun) {
continue;
}
inRun = true;
count++;
} else {
inRun = false;
}
}
return count;
}
public static void main(String[] args) {
int[] arr = { 11022, 1100021, 12123333 };
for (int val : arr) {
int count = sum(val);
String group = "groups";
if (count == 1) {
group = "group";
}
System.out.printf("%d = %d %s with the same number%n", val, count, group);
}
}
Output is the requested
11022 = 2 groups with the same number
1100021 = 2 groups with the same number
12123333 = 1 group with the same number
As for your second question, you might read Integer into a List - Java arrays are immutable,
List<Integer> al = new ArrayList<>();
Scanner scan = new Scanner(System.in);
while (scan.hasNextInt()) {
al.add(scan.nextInt());
}
Integer[] arr = al.toArray(new Integer[0]);
System.out.println(Arrays.toString(arr));

Categories

Resources