Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Banking_Application/Banking_Application.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
12 changes: 12 additions & 0 deletions Hacktoberfest2021.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/BUNCH OF JAVA PROGRAMS" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Java" isTestSource="false" packagePrefix="com.company" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
33 changes: 33 additions & 0 deletions Java/AnagramString.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.company;

import java.util.Arrays;

public class AnagramString {
public static void main(String[] args) {

String str1="geeks";
String str2="skeeg";


if (str1.length()!=str2.length()) {
System.out.println("String is not anagram...");
return;
}
char ch1[]=str1.toCharArray();
char ch2[]=str2.toCharArray();


Arrays.sort(ch1);
Arrays.sort(ch2);


if (Arrays.equals(ch1, ch2)) {

System.out.println("String is anagrams...");
}
else {
System.out.println("String is not anagrams....");
}

}
}
87 changes: 87 additions & 0 deletions Java/Apple_Priceing.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package com.company;

import java.util.Arrays;

public class Apple_Priceing {

public static void name() {
int prices[] = {3, 5, 8, 10};
int demands[] = {1, 6, 10};

int m=prices.length;
int n=demands.length;



Arrays.sort(prices);

boolean used[]=new boolean[m];
int result[]=new int[n];

for (int i = 0; i < n; i++) {
int demand=demands[i];

int choosen=-1;

for (int j = m-1;j>=0; j--) {

if (!used[j] && prices[j]<=demand) {

choosen=prices[j];
used[j]=true;
break;

}
}
result[i]=choosen;

}


for (int i = 0; i < result.length; i++) {

System.out.print(result[i]+" ");
}


}




public static void main(String[] args) {


int prices[] = {3, 5, 8, 10};
int demands[] = {1, 6, 10};

int m = prices.length;
int n = demands.length;


Arrays.sort(prices);

boolean used[] = new boolean[m]; // Track whether apple at index j is sold
int results[] = new int[n]; // Output results for each customer

for (int i = 0; i < n; i++) {
int demand = demands[i];
int chosen = -1;

// Loop through prices from high to low (right to left)
for (int j = m - 1; j >= 0; j--) {
if (!used[j] && prices[j] <= demand) {
chosen = prices[j];
used[j] = true; // Mark this apple as sold
break;
}
}
results[i] = chosen;
}

// Print the result
for (int i = 0; i < n; i++) {
System.out.print(results[i] + " ");
}
}
}
44 changes: 44 additions & 0 deletions Java/Rotate_Array.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.company;

public class Rotate_Array {
public static void reverse(int arr[],int a,int b){

while(a<b){
int t=arr[a];
arr[a]=arr[b];
arr[b]=t;
a++;
b--;
}
}
public static void rotate1(int[] arr, int k) {

k=k%arr.length;

if(arr.length==1){
return;
}

reverse(arr,0,arr.length-1);

int a=0,b=k-1;
reverse(arr, a, b);

a=k;b=arr.length-1;
reverse(arr, a, b);

}

public static void main(String[] args) {

int[] nums ={1,2,3,4,5,6,7};
int k = 3;

rotate1(nums, k);

for (int i : nums) {
System.out.print(i+" ");
}

}
}
73 changes: 73 additions & 0 deletions Java/TransposeMatrix.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.company;

import java.util.Scanner;

public class TransposeMatrix {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);


System.out.println("Enter the row size:");
int row=scanner.nextInt();
System.out.println("Enter the column size:");
int col=scanner.nextInt();

if(row==col) {




int arr[][]=new int[row][col];

int trans[][]=new int[row][col];

System.out.println("Enter elements matrix:");
for (int i = 0; i < row; i++) {

for (int j = 0; j < col; j++) {

arr[i][j]=scanner.nextInt();

}
}

System.out.println("elements :");
for (int i = 0; i < row; i++) {

for (int j = 0; j < col; j++) {

System.out.print(arr[i][j]+" ");

}
System.out.println();
}
System.out.println("Transpose :");
for (int i = 0; i < row; i++) {

for (int j = 0; j < col; j++) {

trans[i][j]=arr[j][i];

}
System.out.println();
}

for (int i = 0; i < row; i++) {

for (int j = 0; j < col; j++) {

System.out.print(trans[i][j]+" ");

}
System.out.println();
}

}
else {
System.out.println("row and column size must be same....");
}

}


}