Compare commits
2 Commits
52f6f2a1a8
...
df7794f8b1
| Author | SHA1 | Date | |
|---|---|---|---|
| df7794f8b1 | |||
| afc94ab8a8 |
Generated
-11
@@ -1,11 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Unnamed" type="Application" factoryName="Application" nameIsGenerated="true">
|
||||
<option name="ALTERNATIVE_JRE_PATH" value="17" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
|
||||
<option name="MAIN_CLASS_NAME" value="Amazon" />
|
||||
<module name="MvnDemo" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
|
||||
public class Alone {
|
||||
public static void main(String[] args) {
|
||||
|
||||
int[] ar = { 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9 };
|
||||
lonelyNum(ar);
|
||||
}
|
||||
|
||||
public static void lonelyNum(int[] arr) {
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
int count = 0;
|
||||
|
||||
for (int k = 0; k < arr.length; k++) {
|
||||
if (arr[i] == arr[k]) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count == 1) {
|
||||
System.out.println(arr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class JavaList {
|
||||
|
||||
public static void main(String[] args) {
|
||||
/*
|
||||
* Enter your code here. Read input from STDIN. Print output to STDOUT. Your
|
||||
* class should be named Solution.
|
||||
*/
|
||||
List<Integer> L = new ArrayList<>();
|
||||
Scanner scan = new Scanner(System.in);
|
||||
System.out.print("Enter the number of Queries: ");
|
||||
int Q = scan.nextInt();
|
||||
while (Q-- > 0) {
|
||||
int N = scan.nextInt();
|
||||
L.add(N);
|
||||
}
|
||||
int x = scan.nextInt();
|
||||
int y = scan.nextInt();
|
||||
L.add(x, y);
|
||||
int xagain = scan.nextInt();
|
||||
L.remove(xagain);
|
||||
for (int i = 0; i < L.size(); i++) {
|
||||
System.out.print(L.get(i) + " ");
|
||||
}
|
||||
scan.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
*
|
||||
* Alone
|
||||
*/
|
||||
public class Alone {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int[] arr = { 1, 1, 1, 3, 4, 4, 5, 5, 5, 5 };
|
||||
System.out.println(lonelyNum(arr));
|
||||
}
|
||||
|
||||
public static int lonelyNum(int[] nums) {
|
||||
int count = 0;
|
||||
nums[0] = 0;
|
||||
for (int x : nums) {
|
||||
for (int i = 0; i < nums.length; i++) {
|
||||
if (x != nums[i]) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
*
|
||||
* Alone
|
||||
*/
|
||||
public class Alonea {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int[] arr = { 1, 1, 1, 3, 4, 4, 5, 5, 5, 5 };
|
||||
System.out.println(lonelyNum(arr));
|
||||
}
|
||||
|
||||
public static int lonelyNum(int[] nums) {
|
||||
int count = 0;
|
||||
int i = nums.length;
|
||||
for (int x : nums) {
|
||||
if (x == nums[i]) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user