Forwarded from Aman Raj
object
al.add(3);
al.add(17);
al.add(6);
al.add(9);
al.add(7);
Q13 Write a program to add elements to HashSet?
import java.util.*;
public class HashSetAddExample {
public static void main(String args[]) {
// initialize HashSet
HashSet<Integer> hs = new HashSet<Integer>();
// add elements to HashSet object
hs.add(3);
hs.add(17);
hs.add(6);
hs.add(9);
hs.add(7);
System.out.println("Using Advanced For Loop");
// printing HashSet
for (Integer num : hs) {
System.out.println(num);
}
}
}
Q14 Write a program to get size of HashMap? (Solution)
You can use the size() method of HashMap class.
Q15 How to check if HashMap is empty? (Solution)
You can check if HashMap is empty using isEmpty() method.
Intermediate level(2-7 year experience) Collection Programs in Java
Q16 Write a program to iterate the HashMap ? (Solution)
There are many ways to iterate the HashMap.The best way to iterate the HashMap is using iterator.
Q17 Write a program to sort HashMap by keys ? (Solution)
You can sort HashMap by keys using TreeMap object.
Q18 Write a program to sort ArrayList using Comparable and Comparator? (Solution)
You can sort ArrayList of Objects using Comparable and Comparator.
Q19 Write a program to sort ArrayList in descending order? (Solution)
You can sort the ArrayList in descending order using Collections.reverseOrder() method.
Q20 Write a program to add element at particular index of ArrayList? (Solution)
You can add element at particular index of ArrayList using method add(int index, Object element).
Q21 Write a program to remove element from specified index of ArrayList? (Solution)
You can remove element at particular index of ArrayList using remove(int index) method.
Q22 Write a program to convert LinkedList to ArrayList? (Solution)
Q23 Write a program to convert HashSet to Array? (Solution)
Q24 Write a program to reverse ArrayList in java? (Solution)
Q25 Write a program to iterate TreeMap in java? (Solution)
Advance Level(7+ years experience) Collection Programs in Java
Q26 Write a program to sort HashMap by value? (Solution)
Q27 How to serialize a HashMap in java? (Solution)
Q28 How to synchronize a HashMap in java? (Solution)
Q29 How to serialize an ArrayList in java? (Solution)
Q30 How to synchronize an ArrayList in java? (Solution)
al.add(3);
al.add(17);
al.add(6);
al.add(9);
al.add(7);
Q13 Write a program to add elements to HashSet?
import java.util.*;
public class HashSetAddExample {
public static void main(String args[]) {
// initialize HashSet
HashSet<Integer> hs = new HashSet<Integer>();
// add elements to HashSet object
hs.add(3);
hs.add(17);
hs.add(6);
hs.add(9);
hs.add(7);
System.out.println("Using Advanced For Loop");
// printing HashSet
for (Integer num : hs) {
System.out.println(num);
}
}
}
Q14 Write a program to get size of HashMap? (Solution)
You can use the size() method of HashMap class.
Q15 How to check if HashMap is empty? (Solution)
You can check if HashMap is empty using isEmpty() method.
Intermediate level(2-7 year experience) Collection Programs in Java
Q16 Write a program to iterate the HashMap ? (Solution)
There are many ways to iterate the HashMap.The best way to iterate the HashMap is using iterator.
Q17 Write a program to sort HashMap by keys ? (Solution)
You can sort HashMap by keys using TreeMap object.
Q18 Write a program to sort ArrayList using Comparable and Comparator? (Solution)
You can sort ArrayList of Objects using Comparable and Comparator.
Q19 Write a program to sort ArrayList in descending order? (Solution)
You can sort the ArrayList in descending order using Collections.reverseOrder() method.
Q20 Write a program to add element at particular index of ArrayList? (Solution)
You can add element at particular index of ArrayList using method add(int index, Object element).
Q21 Write a program to remove element from specified index of ArrayList? (Solution)
You can remove element at particular index of ArrayList using remove(int index) method.
Q22 Write a program to convert LinkedList to ArrayList? (Solution)
Q23 Write a program to convert HashSet to Array? (Solution)
Q24 Write a program to reverse ArrayList in java? (Solution)
Q25 Write a program to iterate TreeMap in java? (Solution)
Advance Level(7+ years experience) Collection Programs in Java
Q26 Write a program to sort HashMap by value? (Solution)
Q27 How to serialize a HashMap in java? (Solution)
Q28 How to synchronize a HashMap in java? (Solution)
Q29 How to serialize an ArrayList in java? (Solution)
Q30 How to synchronize an ArrayList in java? (Solution)
👍1
1920. Build Array from Permutation
Easy
2.2K
240
Companies
Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and return it.
A zero-based permutation nums is an array of distinct integers from 0 to nums.length - 1 (inclusive).
Example 1:
Input: nums = [0,2,1,5,3,4]
Output: [0,1,2,4,5,3]
Explanation: The array ans is built as follows:
ans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]
= [nums[0], nums[2], nums[1], nums[5], nums[3], nums[4]]
= [0,1,2,4,5,3]
Example 2:
Input: nums = [5,0,1,2,3,4]
Output: [4,5,0,1,2,3]
Explanation: The array ans is built as follows:
ans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]
= [nums[5], nums[0], nums[1], nums[2], nums[3], nums[4]]
= [4,5,0,1,2,3]
Constraints:
1 <= nums.length <= 1000
0 <= nums[i] < nums.length
The elements in nums are distinct.
Easy
2.2K
240
Companies
Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and return it.
A zero-based permutation nums is an array of distinct integers from 0 to nums.length - 1 (inclusive).
Example 1:
Input: nums = [0,2,1,5,3,4]
Output: [0,1,2,4,5,3]
Explanation: The array ans is built as follows:
ans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]
= [nums[0], nums[2], nums[1], nums[5], nums[3], nums[4]]
= [0,1,2,4,5,3]
Example 2:
Input: nums = [5,0,1,2,3,4]
Output: [4,5,0,1,2,3]
Explanation: The array ans is built as follows:
ans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]
= [nums[5], nums[0], nums[1], nums[2], nums[3], nums[4]]
= [4,5,0,1,2,3]
Constraints:
1 <= nums.length <= 1000
0 <= nums[i] < nums.length
The elements in nums are distinct.
waylonworldwebdesignerspvtltd@gmail.com
Can send your resumes here
Location:- banglore
Salary range 15-35k
Requirements FullStack developer
Mass HIRING startup culture new technologies to learn and
Greetings Waylon World web designers,
We are looking for fullstack mobile application developers with experience,
Skills required any of the following:
1) Kotlin
2) Flutter
3) React native
4) Angularjs
5) Node
6) Laravel php
7) AWS , other servers
8) Mysql
9) xcode
please feel free to call or message us.
Thank you
Projects for java , React-Js, react next, and many more they have
Can send your resumes here
Location:- banglore
Salary range 15-35k
Requirements FullStack developer
Mass HIRING startup culture new technologies to learn and
Greetings Waylon World web designers,
We are looking for fullstack mobile application developers with experience,
Skills required any of the following:
1) Kotlin
2) Flutter
3) React native
4) Angularjs
5) Node
6) Laravel php
7) AWS , other servers
8) Mysql
9) xcode
please feel free to call or message us.
Thank you
Projects for java , React-Js, react next, and many more they have
Available for immediate joiners let me know once you send resumes we will try to manage for your job
In call with some more organization let me confirm then will do share details if it's a mass Hiring
If you aren't able to mail from Outlook kindly use Gmail it will be done if still not do please share your resumes @stockkida for further process