diff --git a/ATM.java b/ATM.java new file mode 100644 index 0000000..e0ed7af --- /dev/null +++ b/ATM.java @@ -0,0 +1,20 @@ +import java.util.*; +import java.lang.*; +import java.io.*; + +/* Name of the class has to be "Main" only if the class is public. */ +class Codechef +{ + public static void main (String[] args) throws java.lang.Exception + { + Scanner sc = new Scanner(System.in); + double withdrawl_bal = sc.nextDouble(); + double curr_bal = sc.nextDouble(); + + if (withdrawl_bal % 5 == 0 && curr_bal >= withdrawl_bal + 0.5){ + curr_bal = curr_bal - (withdrawl_bal + 0.5); + } + // your code goes here + System.out.printf("%.2f",curr_bal); + } +} diff --git a/AWT/TrafficLight.java b/AWT/TrafficLight.java new file mode 100644 index 0000000..acc435d --- /dev/null +++ b/AWT/TrafficLight.java @@ -0,0 +1,89 @@ +import java.awt.*; +import javax.swing.*; +import java.awt.event.*; + +class Signal extends JPanel{ + Color on; + boolean change; + Signal(Color color){ + on=color; + change=false; + } + public void turnOn(boolean a){ + change=a; + repaint(); + } + public Dimension getPreferredSize(){ + int size=(50)*2; + return new Dimension(size,size); + } + public void paintComponent(Graphics g){ + g.setColor(Color.black); + g.fillRect(0,0,150,250); + if(change){ + g.setColor(on); + } + else{ + g.setColor(Color.white); + } + g.fillOval(10,10,80,80); + } +} + +public class TrafficLight extends JFrame implements ActionListener{ + JRadioButton buttonRed,buttonYellow,buttonGreen; + Signal green=new Signal(Color.green); + Signal yellow=new Signal(Color.yellow); + Signal red=new Signal(Color.red); + + public TrafficLight(){ + setLayout(new FlowLayout()); + buttonRed=new JRadioButton("Red"); + buttonYellow=new JRadioButton("Yellow"); + buttonGreen=new JRadioButton("Green"); + buttonRed.addActionListener(this); + buttonYellow.addActionListener(this); + buttonGreen.addActionListener(this); + JPanel trafficPanel=new JPanel(new GridLayout(3,1)); + trafficPanel.add(red); + trafficPanel.add(yellow); + trafficPanel.add(green); + JPanel lightPanel=new JPanel(new FlowLayout()); + lightPanel.add(buttonRed); + lightPanel.add(buttonYellow); + lightPanel.add(buttonGreen); + add(trafficPanel); + add(lightPanel); + pack(); + setVisible(true); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } + + public static void main(String args[]){ + new TrafficLight(); + } + + public void actionPerformed(ActionEvent e){ + if(e.getSource()==buttonRed){ + green.turnOn(false); + yellow.turnOn(false); + red.turnOn(true); + buttonYellow.setSelected(false); + buttonGreen.setSelected(false); + } + else if(e.getSource()==buttonYellow){ + green.turnOn(false); + yellow.turnOn(true); + red.turnOn(false); + buttonRed.setSelected(false); + buttonGreen.setSelected(false); + } + else if(e.getSource()==buttonGreen){ + green.turnOn(true); + yellow.turnOn(false); + red.turnOn(false); + buttonYellow.setSelected(false); + buttonRed.setSelected(false); + } + } +} diff --git a/AWT/hello.java b/AWT/hello.java new file mode 100644 index 0000000..0a55a80 --- /dev/null +++ b/AWT/hello.java @@ -0,0 +1,8 @@ +import java.util.Scanner; +class hello +{ + public static void main(String[] args) + { + System.out.println("Hello"); + } +} diff --git a/Anagram.java b/Anagram.java new file mode 100644 index 0000000..7ea74ce --- /dev/null +++ b/Anagram.java @@ -0,0 +1,32 @@ +import java.io.*; +import java.util.*; +class Anagram{ + public static void main(String args[]){ + String str1,str2; + Scanner sc=new Scanner(System.in); + System.out.println("Enter the String 1"); + str1=sc.nextLine(); + System.out.println("Enter the String 2"); + str2=sc.nextLine(); + if(str1.length()!=str2.length()){ + System.out.println("The Strings "+str1+" and"+str2+" is not a Anagram"); + } + else{ + str1=str1.toLowerCase(); + str2=str2.toLowerCase(); + char[]arr1=str1.toCharArray(); + char []arr2=str2.toCharArray(); + Arrays.sort(arr1); + Arrays.sort(arr2); + if(Arrays.equals(arr1,arr2)==true){ + System.out.println("The Strings "+str1+" and"+str2+" is a Anagram"); + } + else{ + System.out.println("The Strings "+str1+" and"+sātr2+" is not a Anagram"); + } + } + } +} + + + \ No newline at end of file diff --git a/Armstrong.java b/Armstrong.java new file mode 100644 index 0000000..e45f127 --- /dev/null +++ b/Armstrong.java @@ -0,0 +1,46 @@ +import java.util.Scanner; +import java.lang.Math; +public class Armstrong +{ + static boolean isArmstrong(int n) + { + int temp, digits=0, last=0, sum=0; + temp=n; + + while(temp>0) + { + temp = temp/10; + digits++; + } + + temp = n; + + while(temp>0) + { + last = temp % 10; + sum += (Math.pow(last, digits)); + temp = temp/10; + } + + if(n==sum) + + return true; + + else return false; +} + + public static void main(String args[]) + { + int num; + Scanner sc= new Scanner(System.in); + System.out.print("Enter the max: "); + + num=sc.nextInt(); + System.out.println("Armstrong Number up to "+ num + " are: "); + sc.close(); + + for(int i=0; i<=num; i++) + if(isArmstrong(i)) + System.out.print(i+ ", "); + } +} \ No newline at end of file diff --git a/ArrayList.java b/ArrayList.java index 57ae00b..d62cd2d 100644 --- a/ArrayList.java +++ b/ArrayList.java @@ -18,6 +18,10 @@ public static void main(String[] args) { System.out.println(arr); //acessing the element by index -->method get(i) System.out.println(arr.get(2)); + //To print the elements or ArrayList.(enhanced loop is used) + for(int element : arr){ + System.out.println(element); + } } } diff --git a/ArrayListIteration.java b/ArrayListIteration.java index 5b7edf6..6e14e50 100644 --- a/ArrayListIteration.java +++ b/ArrayListIteration.java @@ -16,7 +16,7 @@ public static void main(String[] args) { System.out.println(course); } - //basic loop with iterator + //basic loop with iterato for(Iterator iterator = courses.iterator();iterator.hasNext();){ String course = (String)iterator.next(); System.out.println(course); @@ -36,4 +36,4 @@ public static void main(String[] args) { // Java 8 forEach + lambda courses.forEach(course -> System.out.println(course)); } -} \ No newline at end of file +} diff --git a/BasicRSA.java b/BasicRSA.java new file mode 100644 index 0000000..07a3936 --- /dev/null +++ b/BasicRSA.java @@ -0,0 +1,72 @@ + +import java.math.BigInteger; +import java.util.Scanner; + +public class BasicRSA{ + + static int gcd(int a, int b) + { /*Returns Greatest common divisor of 2 numbers + *implementing Euclidean ALgorithm */ + + if (a == 0) return b; + else return gcd(b % a, a); + } + + static int modInv(int a, int b) + { /*Returns modular inverse of a mod b + *implementing Extended Euclidean ALgorithm*/ + return modInv(a,b,b,0,1); + } + + static int modInv(int a,int b,int c,int x,int y) + { //over-loading + + if(b%a==0) return y; + else return modInv(b%a,a,c,y,c+(x-(b/a)*y)%c ); + } + + public static void main(String args[]){ + + Scanner sc= new Scanner(System.in); + System.out.println("You are required to enter 2 prime numbers followed by the message you want to encrypt"); + + System.out.println("Enter first prime :"); + int p= sc.nextInt(); + + System.out.println("Enter Second prime:"); + int q=sc.nextInt(); + + System.out.println("Enter a num to encrypt:"); + int m=sc.nextInt(); + //Plaintext: message to be encrypted + + sc.close(); + + int n=p*q; + int z=(p-1)*(q-1)/gcd(p-1,q-1); + int e,d=0; // e is for public key exponent, d is for private key exponent + + for (e = 2; e < z; e++) { + if (gcd(e, z) == 1) { + break; + } + } + + d=modInv(e,z); + + BigInteger M= BigInteger.valueOf(m); + BigInteger E= BigInteger.valueOf(e); + BigInteger N= BigInteger.valueOf(n); + BigInteger D= BigInteger.valueOf(d); + BigInteger C= M.modPow(E,N); + BigInteger M2= C.modPow(D,N); + + + + System.out.println("Public Key Pair : " + e + " " + n ); + System.out.println("Private Key Pair : " + d + " " + n ); + System.out.println("Encrypted num : "+ C); + System.out.println("Decrypted num : "+ M2); + System.out.println("This is deciphered using Private key"); + } +} diff --git a/BinarySearch.java b/BinarySearch.java new file mode 100644 index 0000000..040e4aa --- /dev/null +++ b/BinarySearch.java @@ -0,0 +1,39 @@ +class BinSearch{ + public void BinarySearach(int[] arr,int left,int right,int val){ + + while(left <= right){ + + int mid = (left + right)/2; + + if(val == arr[mid]){ + System.out.println("Element found at index : " + mid); + break; + } + + else if(arr[mid] < val){ + left = val + 1; + } + + else{ + right = mid-1; + } + + if(left > right){ + System.out.println("Element Not Found"); + } + + } + + } +} + +public class BinarySearch{ + public static void main(String[] args) { + BinSearch bs = new BinSearch(); + + int[] arr = {1,2,3,4,5}; + + bs.BinarySearach(arr, 0, arr.length-1, 3); + bs.BinarySearach(arr, 0, arr.length-1, 7); + } +} \ No newline at end of file diff --git a/BinaryTree.java b/BinaryTree.java new file mode 100644 index 0000000..c9de616 --- /dev/null +++ b/BinaryTree.java @@ -0,0 +1,103 @@ +// Java program to print top +// view of binary tree +import java.util.LinkedList; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Queue; +import java.util.TreeMap; + +// class to create a node +class Node { + int data; + Node left, right; + + public Node(int data) + { + this.data = data; + left = right = null; + } +} + +// class of binary tree +class BinaryTree { + Node root; + + public BinaryTree() { root = null; } + + // function should print the topView of + // the binary tree + private void TopView(Node root) + { + class QueueObj { + Node node; + int hd; + + QueueObj(Node node, int hd) + { + this.node = node; + this.hd = hd; + } + } + Queue q = new LinkedList(); + Map topViewMap + = new TreeMap(); + + if (root == null) { + return; + } + else { + q.add(new QueueObj(root, 0)); + } + + System.out.println( + "The top view of the tree is : "); + + // count function returns 1 if the container + // contains an element whose key is equivalent + // to hd, or returns zero otherwise. + while (!q.isEmpty()) { + QueueObj tmpNode = q.poll(); + if (!topViewMap.containsKey(tmpNode.hd)) { + topViewMap.put(tmpNode.hd, tmpNode.node); + } + + if (tmpNode.node.left != null) { + q.add(new QueueObj(tmpNode.node.left, + tmpNode.hd - 1)); + } + if (tmpNode.node.right != null) { + q.add(new QueueObj(tmpNode.node.right, + tmpNode.hd + 1)); + } + } + for (Entry entry : + topViewMap.entrySet()) { + System.out.print(entry.getValue().data); + } + } + + // Driver Program to test above functions + public static void main(String[] args) + { + /* Create following Binary Tree + 1 + / \ + 2 3 + \ + 4 + \ + 5 + \ + 6*/ + BinaryTree tree = new BinaryTree(); + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.right = new Node(4); + tree.root.left.right.right = new Node(5); + tree.root.left.right.right.right = new Node(6); + System.out.println( + "Following are nodes in top view of Binary Tree"); + tree.TopView(tree.root); + } +} diff --git a/BogoSort.java b/BogoSort.java new file mode 100644 index 0000000..24eab33 --- /dev/null +++ b/BogoSort.java @@ -0,0 +1,50 @@ +public class BogoSort +{ + public static void main(String[] args) + { + int[] arr={4,5,6,0,7,8,9,1,2,3}; + + BogoSort now=new BogoSort(); + System.out.print("Unsorted is "); + now.display1D(arr); + + now.bogo(arr); + + System.out.print("Sorted is "); + now.display1D(arr); + } + void bogo(int[] arr) + { + int shuffle=1; + for(;!isSorted(arr);shuffle++) + shuffle(arr); + //Boast + System.out.println("This took "+shuffle+" shuffles"); + } + void shuffle(int[] arr) + { + int i=arr.length-1; + while(i>0) + swap(arr,i--,(int)(Math.random()*i)); + } + void swap(int[] arr,int i,int j) + { + int temp=arr[i]; + arr[i]=arr[j]; + arr[j]=temp; + } + boolean isSorted(int[] arr) + { + + for(int i=1;i map = new TreeMap<>(); + + // Queue to store tree nodes in level order traversal + Queue queue = new LinkedList(); + + // Assign initialized horizontal distance value to root + // node and add it to the queue. + root.hd = hd; + queue.add(root); + + // Loop until the queue is empty (standard level order loop) + while (!queue.isEmpty()) + { + Node temp = queue.remove(); + + // Extract the horizontal distance value from the + // dequeued tree node. + hd = temp.hd; + + // Put the dequeued tree node to TreeMap having key + // as horizontal distance. Every time we find a node + // having same horizontal distance we need to replace + // the data in the map. + map.put(hd, temp.data); + + // If the dequeued node has a left child add it to the + // queue with a horizontal distance hd-1. + if (temp.left != null) + { + temp.left.hd = hd-1; + queue.add(temp.left); + } + // If the dequeued node has a right child add it to the + // queue with a horizontal distance hd+1. + if (temp.right != null) + { + temp.right.hd = hd+1; + queue.add(temp.right); + } + } + + // Extract the entries of map into a set to traverse + // an iterator over that. + Set> set = map.entrySet(); + + // Make an iterator + Iterator> iterator = set.iterator(); + + // Traverse the map elements using the iterator. + while (iterator.hasNext()) + { + Map.Entry me = iterator.next(); + System.out.print(me.getValue()+" "); + } + } +} + +// Main driver class +public class BottomView +{ + public static void main(String[] args) + { + Node root = new Node(20); + root.left = new Node(8); + root.right = new Node(22); + root.left.left = new Node(5); + root.left.right = new Node(3); + root.right.left = new Node(4); + root.right.right = new Node(25); + root.left.right.left = new Node(10); + root.left.right.right = new Node(14); + Tree tree = new Tree(root); + System.out.println("Bottom view of the given binary tree:"); + tree.bottomView(); + } +} diff --git a/BubbleSort.java b/BubbleSort.java index c7a4a13..dbb3ee1 100644 --- a/BubbleSort.java +++ b/BubbleSort.java @@ -1,3 +1,5 @@ + // This is a buuble sort program made with JAVA + import java.lang.*; public class BubbleSort { diff --git a/BucketSort.java b/BucketSort.java new file mode 100644 index 0000000..86fae1a --- /dev/null +++ b/BucketSort.java @@ -0,0 +1,52 @@ + +import java.util.*; +import java.util.Collections; + +class BucketSort { + + static void bucketSort(float arr[], int n) + { + if (n <= 0) + return; + + Vector[] buckets = new Vector[n]; + + for (int i = 0; i < n; i++) { + buckets[i] = new Vector(); + } + + // Put array elements in different buckets + for (int i = 0; i < n; i++) { + float idx = arr[i] * n; + buckets[(int)idx].add(arr[i]); + } + + // Sort individual buckets + for (int i = 0; i < n; i++) { + Collections.sort(buckets[i]); + } + + // Concatenate all buckets + int index = 0; + for (int i = 0; i < n; i++) { + for (int j = 0; j < buckets[i].size(); j++) { + arr[index++] = buckets[i].get(j); + } + } + } + + public static void main(String args[]) + { + float arr[] = { (float)0.89, (float)0.55, + (float)0.65, (float)0.124, + (float)0.66, (float)0.34 }; + + int n = arr.length; + bucketSort(arr, n); + + System.out.println("Sorted array is "); + for (float el : arr) { + System.out.print(el + " "); + } + } +} diff --git a/Buzz.java b/Buzz.java new file mode 100644 index 0000000..be2710e --- /dev/null +++ b/Buzz.java @@ -0,0 +1,19 @@ +import java.util.*; +public class Buzz +{ + public static void main(String args[]) + { + int n; + Scanner scan=new Scanner(System.in); + System.out.print("Enter a number: "); + n=scan.nextInt(); + if(n%7==0||n%10==7) + { + System.out.println(n+" is a Buzz number"); + } + else + { + System.out.println(n+" is not a Buzz number"); + } + } +} diff --git a/Calculator.java b/Calculator.java new file mode 100644 index 0000000..e347fc6 --- /dev/null +++ b/Calculator.java @@ -0,0 +1,73 @@ +import java.util.Scanner; + +public class Calculator { + + public static void main(String[] args) { + + Scanner input = new Scanner(System.in); + + int ans = 0; + + while (true) { + + System.out.print("Enter a operator [+ - * / %] = "); + + char op = input.next().trim().charAt(0); + + if (op == '+' || op == '-' || op == '*' || op == '/' || op == '%') { + + System.out.print("Enter one numbers : "); + + int num1 = input.nextInt(); + + System.out.print("Enter two numbers : "); + + int num2 = input.nextInt(); + + if (op == '+') { + + ans = num1 + num2; + + } + + if (op == '-') { + + ans = num1 - num2; + + } + + if (op == '*') { + + ans = num1 * num2; + + } + + if (op == '/') { + + if (num2 != 0) { + + ans = num1 / num2; + + } + + } + + if (op == '%') { + + ans = num1 % num2; + + } + + } else if (op == 'x' || op == 'X') { + + break; + + } + + System.out.println("Result = " + ans); + + } + + } + +} diff --git a/Catalan.java b/Catalan.java new file mode 100644 index 0000000..dd04ce6 --- /dev/null +++ b/Catalan.java @@ -0,0 +1,45 @@ +import java.util.Scanner; + +class Catalan { + + // find nth Catalan number + public static int catalanDP(int n) + { + + int cat[] = new int[n + 2]; + + // Initialize first two values in table + cat[0] = 1; + cat[1] = 1; + + for (int i = 2; i <= n; i++) { + cat[i] = 0; + for (int j = 0; j < i; j++) { + cat[i] += cat[j] * cat[i - j - 1]; + } + } + + // Return last entry + return cat[n]; + } + + // Driver code + public static void main(String[] args) + { + + // Catalan numbers are a sequence of positive integers, where the nth term in the sequence, denoted Cn, + // is found in the following formula: (2n)! / ((n + 1)!n!) + + Scanner in = new Scanner(System.in); + System.out.println("Enter n (upto 20th catalan numbers will be printed): "); + int n = in.nextInt(); + while(n>=20 || n<=0){ + System.out.print("Enter n < 20: "); + n = in.nextInt(); + } + in.close(); + for (int i = 0; i < n; i++) { + System.out.print(catalanDP(i) + " "); + } + } +} diff --git a/CircularLinkedlist.cpp b/CircularLinkedlist.cpp new file mode 100644 index 0000000..435efaf --- /dev/null +++ b/CircularLinkedlist.cpp @@ -0,0 +1,68 @@ +#include +using namespace std; + +/* structure for a node */ +class Node +{ + public: + int data; + Node *next; +}; + +/* Function to insert a node at the beginning +of a Circular linked list */ +void push(Node **head_ref, int data) +{ + Node *ptr1 = new Node(); + Node *temp = *head_ref; + ptr1->data = data; + ptr1->next = *head_ref; + + /* If linked list is not NULL then + set the next of last node */ + if (*head_ref != NULL) + { + while (temp->next != *head_ref) + temp = temp->next; + temp->next = ptr1; + } + else + ptr1->next = ptr1; /*For the first node */ + + *head_ref = ptr1; +} + +/* Function to print nodes in +a given Circular linked list */ +void printList(Node *head) +{ + Node *temp = head; + if (head != NULL) + { + do + { + cout << temp->data << " "; + temp = temp->next; + } + while (temp != head); + } +} + +/* Driver program to test above functions */ +int main() +{ + /* Initialize lists as empty */ + Node *head = NULL; + + /* Created linked list will be 11->2->56->12 */ + push(&head, 12); + push(&head, 56); + push(&head, 2); + push(&head, 11); + + cout << "Contents of Circular Linked List\n "; + printList(head); + + return 0; +} + diff --git a/DECIMAL2HEXA b/DECIMAL2HEXA new file mode 100644 index 0000000..6aee32c --- /dev/null +++ b/DECIMAL2HEXA @@ -0,0 +1,28 @@ +import java.util.Scanner; + +public class JavaProgram +{ + public static void main(String args[]) + { + int decnum, rem; + String hexdecnum=""; + + + char hex[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; + + Scanner scan = new Scanner(System.in); + + System.out.print("Enter Decimal Number : "); + decnum = scan.nextInt(); + + while(decnum>0) + { + rem = decnum%16; + hexdecnum = hex[rem] + hexdecnum; + decnum = decnum/16; + } + + System.out.print("Equivalent Hexadecimal Value of " + decnum + " is :\n"); + System.out.print(hexdecnum); + } +} diff --git a/DesignCircularQueue.java b/DesignCircularQueue.java new file mode 100644 index 0000000..f12c917 --- /dev/null +++ b/DesignCircularQueue.java @@ -0,0 +1,81 @@ +//Design Circular Queue + + class MyCircularQueue { + + private int[] data; + private int head; + private int tail; + private int size; + + /** Initialize your data structure here. Set the size of the queue to be k. */ + public MyCircularQueue(int k) { + data = new int[k]; + head = -1; + tail = -1; + size = k; + } + + /** Insert an element into the circular queue. Return true if the operation is successful. */ + public boolean enQueue(int value) { + if (isFull() == true) { + return false; + } + if (isEmpty() == true) { + head = 0; + } + tail = (tail + 1) % size; + data[tail] = value; + return true; + } + + /** Delete an element from the circular queue. Return true if the operation is successful. */ + public boolean deQueue() { + if (isEmpty() == true) { + return false; + } + if (head == tail) { + head = -1; + tail = -1; + return true; + } + head = (head + 1) % size; + return true; + } + + /** Get the front item from the queue. */ + public int Front() { + if (isEmpty() == true) { + return -1; + } + return data[head]; + } + + /** Get the last item from the queue. */ + public int Rear() { + if (isEmpty() == true) { + return -1; + } + return data[tail]; + } + + /** Checks whether the circular queue is empty or not. */ + public boolean isEmpty() { + return head == -1; + } + + /** Checks whether the circular queue is full or not. */ + public boolean isFull() { + return ((tail + 1) % size) == head; + } +} + +/** + * Your MyCircularQueue object will be instantiated and called as such: + * MyCircularQueue obj = new MyCircularQueue(k); + * boolean param_1 = obj.enQueue(value); + * boolean param_2 = obj.deQueue(); + * int param_3 = obj.Front(); + * int param_4 = obj.Rear(); + * boolean param_5 = obj.isEmpty(); + * boolean param_6 = obj.isFull(); + */ diff --git a/Diamond_Pattern.java b/Diamond_Pattern.java new file mode 100644 index 0000000..d260b43 --- /dev/null +++ b/Diamond_Pattern.java @@ -0,0 +1,39 @@ +import java.util.Scanner; +public class Diamond +{ + public static void main(String args[]) + { + int n, i, j, space = 1; + System.out.print("Enter the number of rows: "); + Scanner s = new Scanner(System.in); + n = s.nextInt(); + space = n - 1; + for (j = 1; j <= n; j++) + { + for (i = 1; i <= space; i++) + { + System.out.print(" "); + } + space--; + for (i = 1; i <= 2 * j - 1; i++) + { + System.out.print("*"); + } + System.out.println(""); + } + space = 1; + for (j = 1; j <= n - 1; j++) + { + for (i = 1; i <= space; i++) + { + System.out.print(" "); + } + space++; + for (i = 1; i <= 2 * (n - j) - 1; i++) + { + System.out.print("*"); + } + System.out.println(""); + } + } +} \ No newline at end of file diff --git a/FloydWarshall.java b/FloydWarshall.java new file mode 100644 index 0000000..892466d --- /dev/null +++ b/FloydWarshall.java @@ -0,0 +1,72 @@ +package DataStructures.Graphs; + +import java.util.Scanner; + +public class FloydWarshall { + private int DistanceMatrix[][]; + private int numberofvertices; + public static final int INFINITY = 999; + + public FloydWarshall(int numberofvertices) { + DistanceMatrix = + new int[numberofvertices + 1] + [numberofvertices + + 1]; + this.numberofvertices = numberofvertices; + } + + public void floydwarshall( + int AdjacencyMatrix[][]) + { + for (int source = 1; source <= numberofvertices; source++) { + for (int destination = 1; destination <= numberofvertices; destination++) { + DistanceMatrix[source][destination] = AdjacencyMatrix[source][destination]; + } + } + for (int intermediate = 1; intermediate <= numberofvertices; intermediate++) { + for (int source = 1; source <= numberofvertices; source++) { + for (int destination = 1; destination <= numberofvertices; destination++) { + if (DistanceMatrix[source][intermediate] + DistanceMatrix[intermediate][destination] + < DistanceMatrix[source][destination]) + { + DistanceMatrix[source][destination] = + DistanceMatrix[source][intermediate] + DistanceMatrix[intermediate][destination]; + } + } + } + } + for (int source = 1; source <= numberofvertices; source++) System.out.print("\t" + source); + System.out.println(); + for (int source = 1; source <= numberofvertices; source++) { + System.out.print(source + "\t"); + for (int destination = 1; destination <= numberofvertices; destination++) { + System.out.print(DistanceMatrix[source][destination] + "\t"); + } + System.out.println(); + } + } + + public static void main(String... arg) { + Scanner scan = new Scanner(System.in); + System.out.println("Enter the number of vertices"); + int numberOfVertices = scan.nextInt(); + int[][] adjacencyMatrix = new int[numberOfVertices + 1][numberOfVertices + 1]; + System.out.println("Enter the Weighted Matrix for the graph"); + for (int source = 1; source <= numberOfVertices; source++) { + for (int destination = 1; destination <= numberOfVertices; destination++) { + adjacencyMatrix[source][destination] = scan.nextInt(); + if (source == destination) { + adjacencyMatrix[source][destination] = 0; + continue; + } + if (adjacencyMatrix[source][destination] == 0) { + adjacencyMatrix[source][destination] = INFINITY; + } + } + } + System.out.println("The Transitive Closure of the Graph"); + FloydWarshall floydwarshall = new FloydWarshall(numberOfVertices); + floydwarshall.floydwarshall(adjacencyMatrix); + scan.close(); + } +} diff --git a/GCD_of_fact_of_two_Numbers.java b/GCD_of_fact_of_two_Numbers.java new file mode 100644 index 0000000..3924d13 --- /dev/null +++ b/GCD_of_fact_of_two_Numbers.java @@ -0,0 +1,32 @@ +// Program to find GCD of Factorial of Two Numbers + +import java.util.Scanner; + +public class GCD_of_fact_of_two_Numbers { + static int factorial(long x) + { + if (x <= 1) //terminating condition + return 1; + int res = 2; + for (int i = 3; i <= x; i++) //calculating factorial of the smaller number + res = res * i; + return res; + } + + static int gcdOfFactorial(long m, long n) + { + long min = Math.min(m, n); //checking which number is smaller + return factorial(min); //Method call for the factorial of smaller number + } + + /* Driver program to test above functions */ + public static void main (String[] args) //main function to initialize variables and call the function + { + long i , j; + Scanner in = new Scanner(System.in); + System.out.print("Enter the values of numbers you want to check : "); + i = in.nextLong() ; //taking inputs from the User say "6" and "8" + j = in.nextLong(); + System.out.println("The GCD of numbers "+ i + " and " + j + " is : " + gcdOfFactorial(i, j)); //Method Call with parameter pass as "i" and "j" + } +} diff --git a/GuessingGame.java b/GuessingGame.java new file mode 100644 index 0000000..9831f9d --- /dev/null +++ b/GuessingGame.java @@ -0,0 +1,8 @@ +public interface GuessingGame { + + void setAnswer(String ans); + void guess(String s); + String getOutput(); + boolean isWon(); + boolean isLost(); +} diff --git a/Hangman.java b/Hangman.java new file mode 100644 index 0000000..1b6ce6a --- /dev/null +++ b/Hangman.java @@ -0,0 +1,77 @@ +public class Hangman implements GuessingGame{ + private String target; + private int life ; + private char[] answer ; + + private boolean fact=false; + public Hangman() { + life = 6; + } + + + + + @Override + public void setAnswer(String ans) { + + target = ans.toLowerCase(); + answer = new char[target.length()]; + for (int i = 0; i 1) { + fact = true; + } else { + for (int i = 0; i < target.length(); i++) { + + if (target.charAt(i) == tmp.charAt(0)) { + answer[i] = tmp.charAt(0); + isCorrect = true; + } + } + if (isCorrect == false) life--; + } + } + + @Override + public String getOutput() { + if(fact == true){ + fact = false; + return "One character only"; + } + String temp=""; + for (int i = 0; i a[i]) + largest=l; + else + largest=i; + + if(ra[largest]) + largest=r; + + if(largest !=i) + { + temp=a[largest]; + a[largest]=a[i]; + a[i]=temp; + + heapify(a,largest,n); + } + + + } + + public static void bheap(int a[]) + { + + for(int i=(a.length/2)-1;i>=0;i--) + { + + heapify(a,i,a.length); + + } + + } + + public static void Sort(int a[]) + { + int temp,j,i; + + bheap(a); + + for( i=(a.length)-1; i>0;) + { + temp=a[0]; + a[0]=a[i]; + a[i]=temp; + heapify(a,0,i--) ; + + } + + } + + public static void printarray(int a[]) + { + System.out.println(); + for (int j : a) { + + System.out.print(j + " "); + } + + } + public static void main(String[] args) + { + int n, res,i; + Scanner s = new Scanner(System.in); + System.out.print("Enter number of elements in the array:"); + n = s.nextInt(); + int[] a = new int[n]; + System.out.println("Enter "+n+" elements "); + for( i=0; i < n; i++) + { + a[i] = s.nextInt(); + } + + System.out.println( "elements in array "); + printarray(a); + Sort(a); + System.out.println( "\nelements after sorting"); + printarray(a); + + } +} diff --git a/K_equal_sum_subset.java b/K_equal_sum_subset.java new file mode 100644 index 0000000..b188a64 --- /dev/null +++ b/K_equal_sum_subset.java @@ -0,0 +1,39 @@ +public class K_equal_sum_subset { + //helper function + boolean helpInPartition(int nums[],boolean visited[],int start,int k,int currentSum,int targetSum) + { + //when there are no more subsets left to make + if(k==0) + return true; + if(currentSum>targetSum) + return false; + //if current sum equals target sum,we are left with k-1 subsets to make + if(currentSum==targetSum) + return helpInPartition(nums,visited,0,k-1,0,targetSum); + for(int j=start;j list1 = new LinkedList<>(); + + List list2 = new LinkedList<>(); + + List resultList = new LinkedList<>(); + + list1.add(1); + list1.add(3); + list1.add(6); + + list2.add(2); + list2.add(4); + list2.add(5); + + int i = 0; + int j = 0; + + while(i < list1.size() && j < list2.size()){ + if(list1.get(i) < list2.get(j)){ + resultList.add(list1.get(i)); + i++; + } + + else{ + resultList.add(list2.get(j)); + j++; + } + } + + while(i < list1.size()){ + resultList.add(list1.get(i)); + i++; + } + + while(j < list2.size()){ + resultList.add(list2.get(j)); + j++; + } + + System.out.print("Resulting List After the Merging the Two Sorted Lists : "); + + for(int k = 0;k Accelerate/ Break) +// He/she does not bather about how the Accelerate/ brake mechanism works internally. This is how the abstraction works. + +// Abstract class +public abstract class Car { + public abstract void stop(); +} + +// Concrete class +public class Ford extends Car { + // Hiding implementation details + @Override + public void stop(){ + System.out.println("Ford::Stop"); + } +} + +public class Main { + public static void main(String args[]){ + Car obj = new Ford(); // Car object + obj.stop(); // Call the method + } +} + diff --git a/OOP Concepts/Encapsulation.java b/OOP Concepts/Encapsulation.java new file mode 100644 index 0000000..88a307f --- /dev/null +++ b/OOP Concepts/Encapsulation.java @@ -0,0 +1,38 @@ +//Encapsulation is the process of wrapping code and data together into a single unit. +//Just like a capsule which is mixed of several medicines. The medicines are hidden data to the end user. + +// A Java class which is a fully encapsulated class. +public class Car{ + + // private variable (Could not access directly) + private String name; + + // getter method for name + public String getName() { + return name; + } + + // setter method for name + public void setName(String name){ + this.name = name + } + +} + + +// Java class to test the encapsulated class. +public class Test{ + + public static void main(String[] args){ + + // creating instance of the encapsulated class + Car car = new Car(); + + // setting value in the name member + car.setName("Ford"); + + // getting value of the name member + System.out.println(car.getName()); + } + +} diff --git a/OOP Concepts/Inheritance.java b/OOP Concepts/Inheritance.java new file mode 100644 index 0000000..b91717d --- /dev/null +++ b/OOP Concepts/Inheritance.java @@ -0,0 +1,70 @@ +//Inheritance is the process of one class inheriting properties and methods from another class in Java. +//It's just like father and son relationship. +//Son inherit fathers things as well as things of his own +//Here is a Car example senario to that + + +// super class +class Car { + // the Car class have one field + public String wheelStatus; + public int noOfWheels; + + // the Car class has one constructor + public Car(String wheelStatus, int noOfWheels) + { + this.wheelStatus = wheelStatus; + this.noOfWheels = noOfWheels; + } + + // the Car class has three methods + public void applyBrake() + { + wheelStatus = "Stop" + } + + // toString() method to print info of Car + public String toString() + { + return ("No of wheels in car " + noOfWheels + "\n" + + "status of the wheels " + wheelStatus); + } +} + +// sub class +class Ford extends Car { + + // the Ford subclass adds one more field + public Boolean alloyWheel; + + // the Ford subclass has one constructor + public Ford(String wheelStatus, int noOfWheels, + Boolean alloyWheel) + { + // invoking super-class(Car) constructor + super(wheelStatus, noOfWheels); + alloyWheel = alloyWheel; + } + + // the Ford subclass adds one more method + public void setAlloyWheel(Boolean alloyWheel) + { + alloyWheel = alloyWheel; + } + + // overriding toString() method of Car to print more info + @Override + public String toString(){ + return (super.toString() + "\nCar alloy wheel " + + alloyWheel); + } +} + +// driver class +public class Main { + public static void main(String args[]){ + + Ford ford = new Ford(3, 100, 25); + System.out.println(ford.toString()); + } +} diff --git a/OOP Concepts/Polymorphism.java b/OOP Concepts/Polymorphism.java new file mode 100644 index 0000000..bf9b8e0 --- /dev/null +++ b/OOP Concepts/Polymorphism.java @@ -0,0 +1,13 @@ +//Polymorphism is the ability to perform many things in many ways. +public class Car{ + + public void speed() { + } + + public void speed(String accelerator) { + } + + public int speed(String accelerator, int speedUp) { + return carSpeed; + } +} diff --git a/PalindromicNumber.java b/PalindromicNumber.java new file mode 100644 index 0000000..b2b49f3 --- /dev/null +++ b/PalindromicNumber.java @@ -0,0 +1,20 @@ +import java.util.*; + +class Solution { + public boolean isPalindrome(int x) { + if(x < 0) return false; + String number = String.valueOf(x); + String[] temp = new String[number.length()]; + String[] tempReverse = new String[number.length()]; + for(int i = 0; i < number.length(); i++){ + temp[i] = String.valueOf(number.charAt(i)); + tempReverse[number.length()-i-1] = String.valueOf(number.charAt(i)); + } + for(int i = 0; i < numberf.length(); i++){ + if(!temp[i].equals(tempReverse[i])){ + return false; + } + } + return true; + } +} diff --git a/PrimsAlgo.java b/PrimsAlgo.java new file mode 100644 index 0000000..83b8267 --- /dev/null +++ b/PrimsAlgo.java @@ -0,0 +1,108 @@ +// A Java program for Prim's Minimum Spanning Tree (MST) algorithm. +// The program is for adjacency matrix representation of the graph + +import java.util.*; +import java.lang.*; +import java.io.*; + +class PrimsAlgo { + // Number of vertices in the graph + private static final int V = 5; + + // A utility function to find the vertex with minimum key + // value, from the set of vertices not yet included in MST + int minKey(int key[], Boolean mstSet[]) + { + // Initialize min value + int min = Integer.MAX_VALUE, min_index = -1; + + for (int v = 0; v < V; v++) + if (mstSet[v] == false && key[v] < min) { + min = key[v]; + min_index = v; + } + + return min_index; + } + + // A utility function to print the constructed MST stored in + // parent[] + void printMST(int parent[], int graph[][]) + { + System.out.println("Edge \tWeight"); + for (int i = 1; i < V; i++) + System.out.println(parent[i] + " - " + i + "\t" + graph[i][parent[i]]); + } + + // Function to construct and print MST for a graph represented + // using adjacency matrix representation + void primMST(int graph[][]) + { + // Array to store constructed MST + int parent[] = new int[V]; + + // Key values used to pick minimum weight edge in cut + int key[] = new int[V]; + + // To represent set of vertices included in MST + Boolean mstSet[] = new Boolean[V]; + + // Initialize all keys as INFINITE + for (int i = 0; i < V; i++) { + key[i] = Integer.MAX_VALUE; + mstSet[i] = false; + } + + // Always include first 1st vertex in MST. + key[0] = 0; // Make key 0 so that this vertex is + // picked as first vertex + parent[0] = -1; // First node is always root of MST + + // The MST will have V vertices + for (int count = 0; count < V - 1; count++) { + // Pick thd minimum key vertex from the set of vertices + // not yet included in MST + int u = minKey(key, mstSet); + + // Add the picked vertex to the MST Set + mstSet[u] = true; + + // Update key value and parent index of the adjacent + // vertices of the picked vertex. Consider only those + // vertices which are not yet included in MST + for (int v = 0; v < V; v++) + + // graph[u][v] is non zero only for adjacent vertices of m + // mstSet[v] is false for vertices not yet included in MST + // Update the key only if graph[u][v] is smaller than key[v] + if (graph[u][v] != 0 && mstSet[v] == false && graph[u][v] < key[v]) { + parent[v] = u; + key[v] = graph[u][v]; + } + } + + // print the constructed MST + printMST(parent, graph); + } + + public static void main(String[] args) + { + /* Let us create the following graph + 2 3 + (0)--(1)--(2) + | / \ | + 6| 8/ \5 |7 + | / \ | + (3)-------(4) + 9 */ + MST t = new MST(); + int graph[][] = new int[][] { { 0, 2, 0, 6, 0 }, + { 2, 0, 3, 8, 5 }, + { 0, 3, 0, 0, 7 }, + { 6, 8, 0, 0, 9 }, + { 0, 5, 7, 9, 0 } }; + + // Print the solution + t.primMST(graph); + } +} diff --git a/Quicksort.java b/Quicksort.java new file mode 100644 index 0000000..9888b3c --- /dev/null +++ b/Quicksort.java @@ -0,0 +1,62 @@ +class QuickSort +{ + public static void main(String[]args) + { + int a[]={10,75,-15,17,0,-2}; + QSort(a,0,a.length-1); + System.out.println("Sorted Array : "); + System.out.print("["); + for(int i=0;ipivot) + { + end--; + } + if(start + + + + + + + + #Java_Programs :coffee: Java is a high-level, class-based, object-oriented programming language that is designed diff --git a/RSA.java b/RSA.java new file mode 100644 index 0000000..4b0dead --- /dev/null +++ b/RSA.java @@ -0,0 +1,73 @@ +package Ciphers; + +import java.math.BigInteger; +import java.security.SecureRandom; +import javax.swing.JOptionPane; + +public final class RSA { + + public static void main(String[] args) { + + RSA rsa = new RSA(1024); + String text1 = JOptionPane.showInputDialog("Enter a message to encrypt :"); + + String ciphertext = rsa.encrypt(text1); + JOptionPane.showMessageDialog(null, "Your encrypted message : " + ciphertext); + + JOptionPane.showMessageDialog(null, "Your message after decrypt : " + rsa.decrypt(ciphertext)); + } + + private BigInteger modulus, privateKey, publicKey; + + public RSA(int bits) { + generateKeys(bits); + } + + /** + * @return encrypted message + */ + public synchronized String encrypt(String message) { + return (new BigInteger(message.getBytes())).modPow(publicKey, modulus).toString(); + } + + /** + * @return encrypted message as big integer + */ + public synchronized BigInteger encrypt(BigInteger message) { + return message.modPow(publicKey, modulus); + } + + /** + * @return plain message + */ + public synchronized String decrypt(String encryptedMessage) { + return new String((new BigInteger(encryptedMessage)).modPow(privateKey, modulus).toByteArray()); + } + + /** + * @return plain message as big integer + */ + public synchronized BigInteger decrypt(BigInteger encryptedMessage) { + return encryptedMessage.modPow(privateKey, modulus); + } + + /** + * Generate a new public and private key set. + */ + public synchronized void generateKeys(int bits) { + SecureRandom r = new SecureRandom(); + BigInteger p = new BigInteger(bits / 2, 100, r); + BigInteger q = new BigInteger(bits / 2, 100, r); + modulus = p.multiply(q); + + BigInteger m = (p.subtract(BigInteger.ONE)).multiply(q.subtract(BigInteger.ONE)); + + publicKey = new BigInteger("3"); + + while (m.gcd(publicKey).intValue() > 1) { + publicKey = publicKey.add(new BigInteger("2")); + } + + privateKey = publicKey.modInverse(m); + } +} diff --git a/Rabin_Karp_Problem.java b/Rabin_Karp_Problem.java new file mode 100644 index 0000000..ee2bb0a --- /dev/null +++ b/Rabin_Karp_Problem.java @@ -0,0 +1,82 @@ +module Rabin_Karp_Problem { + // Following program is a Java implementation + // of Rabin Karp Algorithm given in the CLRS book + + public class Main { + // d is the number of characters in the input alphabet + public final static int d = 256; + + /* pat -> pattern + txt -> text + q -> A prime number + */ + static void search(String pat, String txt, int q) + { + int M = pat.length(); + int N = txt.length(); + int i, j; + int p = 0; // hash value for pattern + int t = 0; // hash value for txt + int h = 1; + + // The value of h would be "pow(d, M-1)%q" + for (i = 0; i < M - 1; i++) + h = (h * d) % q; + + // Calculate the hash value of pattern and first + // window of text + for (i = 0; i < M; i++) { + p = (d * p + pat.charAt(i)) % q; + t = (d * t + txt.charAt(i)) % q; + } + + // Slide the pattern over text one by one + for (i = 0; i <= N - M; i++) { + + // Check the hash values of current window of + // text and pattern. If the hash values match + // then only check for characters one by one + if (p == t) { + /* Check for characters one by one */ + for (j = 0; j < M; j++) { + if (txt.charAt(i + j) != pat.charAt(j)) + break; + } + + // if p == t and pat[0...M-1] = txt[i, i+1, + // ...i+M-1] + if (j == M) + System.out.println( + "Pattern found at index " + i); + } + + // Calculate hash value for next window of text: + // Remove leading digit, add trailing digit + if (i < N - M) { + t = (d * (t - txt.charAt(i) * h) + + txt.charAt(i + M)) + % q; + + // We might get negative value of t, + // converting it to positive + if (t < 0) + t = (t + q); + } + } + } + + /* Driver Code */ + public static void main(String[] args) + { + String txt = "GEEKS FOR GEEKS"; + String pat = "GEEK"; + + // A prime number + int q = 101; + + // Function Call + search(pat, txt, q); + } + } + +} \ No newline at end of file diff --git a/RadixSort.java b/RadixSort.java new file mode 100644 index 0000000..3de40f3 --- /dev/null +++ b/RadixSort.java @@ -0,0 +1,48 @@ +package Sorts; + +import java.util.Arrays; + +class RadixSort { + + private static int getMax(int[] arr, int n) { + int mx = arr[0]; + for (int i = 1; i < n; i++) if (arr[i] > mx) mx = arr[i]; + return mx; + } + + private static void countSort(int[] arr, int n, int exp) { + int[] output = new int[n]; + int i; + int[] count = new int[10]; + Arrays.fill(count, 0); + + for (i = 0; i < n; i++) count[(arr[i] / exp) % 10]++; + + for (i = 1; i < 10; i++) count[i] += count[i - 1]; + + for (i = n - 1; i >= 0; i--) { + output[count[(arr[i] / exp) % 10] - 1] = arr[i]; + count[(arr[i] / exp) % 10]--; + } + + for (i = 0; i < n; i++) arr[i] = output[i]; + } + + private static void radixsort(int[] arr, int n) { + + int m = getMax(arr, n); + + for (int exp = 1; m / exp > 0; exp *= 10) countSort(arr, n, exp); + } + + static void print(int[] arr, int n) { + for (int i = 0; i < n; i++) System.out.print(arr[i] + " "); + } + + public static void main(String[] args) { + int[] arr = {170, 45, 75, 90, 802, 24, 2, 66}; + int n = arr.length; + radixsort(arr, n); + print(arr, n); + } +} \ No newline at end of file diff --git a/ReverseString.java b/ReverseString.java new file mode 100644 index 0000000..91be83b --- /dev/null +++ b/ReverseString.java @@ -0,0 +1,26 @@ +import java.lang.*; +import java.io.*; +import java.util.*; + +class ReverseString { + public static void main(String[] args) + { + String str = "Hacktoberfast2021"; + + System.out.println(reverseStr(str)); + } + + public static String reverseStr(String input) { + + byte[] byteArray = input.getBytes(); + + byte[] byteResult = new byte[byteArray.length]; + + + for (int i = 0; i < byteArray.length; i++) + byteResult[i] = byteArray[byteArray.length - i - 1]; + + return new String(byteResult); + + } +} diff --git a/Searching.java b/Searching.java new file mode 100644 index 0000000..f1f6383 --- /dev/null +++ b/Searching.java @@ -0,0 +1,37 @@ +import java.util.Scanner; +public class Searching { + public static int search(int arr[], int x) { + for (int i = 0; i < arr.length; i++) { + if (arr[i] == x) { + return i; + } + } + return -1; + } + public static void main(String[] args) { + Scanner input = new Scanner(System.in); + int arr[] = { + 10, + 20, + 30, + 40, + 50, + 60, + 70, + 80, + 90, + 100 + }; + System.out.print("Enter the number: "); + int x = input.nextInt(); + System.out.println(); + + int result = search(arr, x); + if (result == -1) { + System.out.println("Sorry, data not found"); + } else { + System.out.println("Number " + x + " in index " + search(arr, x) + ""); + } + } + +} diff --git a/SelectionSort10 b/SelectionSort10 new file mode 100644 index 0000000..1db46bd --- /dev/null +++ b/SelectionSort10 @@ -0,0 +1,41 @@ +import java.io.*; + +public class SelectionSort10 { + public static void selsort(int A[]) { + int i, j, small, tmp, pos; + for (i = 0; i < 10; i++) { + small = A[i]; + pos = i; + for (j = i + 1; j < 10; j++) { + if (A[j] < small) { + small = A[j]; + pos = j; + } + } + tmp = A[i]; + A[i] = A[pos]; + A[pos] = tmp; + } + System.out.println("Array in ascending order="); + for (i = 0; i < 10; i++) + System.out.println(A[i]); + } + + public static void main(String[] args) { + int A[] = new int[10]; + BufferedReader buf = new BufferedReader(new InputStreamReader(System.in)); + String inStr = null; + System.out.println("Enter 10 elements of array="); + try { + for (int i = 0; i < 10; i++) { + inStr = buf.readLine(); + A[i] = Integer.parseInt(inStr); + } + } catch (Exception e) { + System.out.println("Error in data entry"); + System.out.println("Exception=" + e); + return; + } + selsort(A); + } +} diff --git a/SieveOfEratosthenes.java b/SieveOfEratosthenes.java new file mode 100644 index 0000000..389750c --- /dev/null +++ b/SieveOfEratosthenes.java @@ -0,0 +1,24 @@ +// Sieve of Eratosthenes is an algorithm that finds all the primes upto a certain number. + +import java.util.Scanner; + +class SieveOfEratosthenes { + public static void main(String args[]) { + int n; + System.out.print("Enter a number: "); + Scanner sc = new Scanner(System.in); + n = sc.nextInt(); + boolean composites[] = new boolean[n + 1]; + + for(int i = 2; i * i <= n; i++) { + if(!composites[i]) + for(int j = i * i; j <= n; j+=i) + composites[j] = true; + } + + System.out.println("Primes:"); + for(int i = 2; i <= n; i++) + if(!composites[i]) + System.out.println(i); + } +} \ No newline at end of file diff --git a/SpiralMatrix.java b/SpiralMatrix.java new file mode 100644 index 0000000..04a165d --- /dev/null +++ b/SpiralMatrix.java @@ -0,0 +1,51 @@ + +import java.util.*; + +class SpiralMatrix{ + + // Function to print in spiral order + public static List spiralOrder(int[][] matrix) + { + List ans = new ArrayList(); + + if (matrix.length == 0) + return ans; + + int R = matrix.length, C = matrix[0].length; + boolean[][] seen = new boolean[R][C]; + int[] dr = { 0, 1, 0, -1 }; + int[] dc = { 1, 0, -1, 0 }; + int r = 0, c = 0, di = 0; + + // Iterate from 0 to R * C - 1 + for (int i = 0; i < R * C; i++) { + ans.add(matrix[r]); + seen[r] = true; + int cr = r + dr[di]; + int cc = c + dc[di]; + + if (0 <= cr && cr < R && 0 <= cc && cc < C + && !seen[cr][cc]) { + r = cr; + c = cc; + } + else { + di = (di + 1) % 4; + r += dr[di]; + c += dc[di]; + } + } + return ans; + } + + // Driver Code + public static void main(String[] args) + { + int a[][] = { { 1, 2, 3, 4 }, + { 5, 6, 7, 8 }, + { 9, 10, 11, 12 }, + { 13, 14, 15, 16 } }; + + System.out.println(spiralOrder(a)); + } +} diff --git a/Structure_.class b/Structure_.class new file mode 100644 index 0000000..3d3b666 Binary files /dev/null and b/Structure_.class differ diff --git a/Subarrays.cpp b/Subarrays.cpp new file mode 100644 index 0000000..c866e85 --- /dev/null +++ b/Subarrays.cpp @@ -0,0 +1,76 @@ +/*C++ program to find total number of +even-odd subarrays present in given array*/ +#include +using namespace std; + +// function that returns the count of subarrays that +// contain equal number of odd as well as even numbers +int countSubarrays(int arr[], int n) +{ + // initialize difference and answer with 0 + int difference = 0; + int ans = 0; + + // create two auxiliary hash arrays to count frequency + // of difference, one array for non-negative difference + // and other array for negative difference. Size of these + // two auxiliary arrays is 'n+1' because difference can + // reach maximum value 'n' as well as minimum value '-n' + int hash_positive[n + 1], hash_negative[n + 1]; + + // initialize these auxiliary arrays with 0 + fill_n(hash_positive, n + 1, 0); + fill_n(hash_negative, n + 1, 0); + + // since the difference is initially 0, we have to + // initialize hash_positive[0] with 1 + hash_positive[0] = 1; + + // for loop to iterate through whole + // array (zero-based indexing is used) + for (int i = 0; i < n ; i++) + { + // incrementing or decrementing difference based on + // arr[i] being even or odd, check if arr[i] is odd + if (arr[i] & 1 == 1) + difference++; + else + difference--; + + // adding hash value of 'difference' to our answer + // as all the previous occurrences of the same + // difference value will make even-odd subarray + // ending at index 'i'. After that, we will increment + // hash array for that 'difference' value for + // its occurrence at index 'i'. if difference is + // negative then use hash_negative + if (difference < 0) + { + ans += hash_negative[-difference]; + hash_negative[-difference]++; + } + + // else use hash_positive + else + { + ans += hash_positive[difference]; + hash_positive[difference]++; + } + } + + // return total number of even-odd subarrays + return ans; +} + +// Driver code +int main() +{ + int arr[] = {3, 4, 6, 8, 1, 10, 5, 7}; + int n = sizeof(arr) / sizeof(arr[0]); + + // Printing total number of even-odd subarrays + cout << "Total Number of Even-Odd subarrays" + " are " << countSubarrays(arr,n); + + return 0; +} diff --git a/TCPClient.java b/TCPClient.java new file mode 100644 index 0000000..b3937d6 --- /dev/null +++ b/TCPClient.java @@ -0,0 +1,23 @@ +import java.io.*; +import java.net.*; + +class TCPClient { + public static void main(String argv[]) throws Exception + { + String sentence; + String modifiedSentence; + + BufferedReader inFromUser =new BufferedReader(new InputStreamReader(System.in)); + + Socket clientSocket = new Socket("localhost", 4444); + + DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream()); + BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); + System.out.println("Enter a message:"); + sentence = inFromUser.readLine(); + outToServer.writeBytes(sentence + '\n'); + modifiedSentence = inFromServer.readLine(); + System.out.println("FROM SERVER: " + modifiedSentence); + clientSocket.close(); + } +} diff --git a/TCPServer.java b/TCPServer.java new file mode 100644 index 0000000..2459778 --- /dev/null +++ b/TCPServer.java @@ -0,0 +1,42 @@ +import java.io.*; +import java.net.*; +class Thr extends Thread +{ + Socket s; + + Thr(){s=null; } + + Thr(Socket s1) { s=s1;} + + public void run() + { + String clientSentence; + String capitalizedSentence; + try{ + BufferedReader inFromClient =new BufferedReader(new InputStreamReader(s.getInputStream())); + DataOutputStream outToClient=new DataOutputStream(s.getOutputStream()); + clientSentence = inFromClient.readLine(); + System.out.println(clientSentence); + capitalizedSentence = clientSentence.toUpperCase() + '\n'; + outToClient.writeBytes(capitalizedSentence); + s.close(); + if(clientSentence.equals("exit")) + System.exit(1); + + } + catch(Exception e){} + } + + } + class TCPServer { + public static void main(String argv[]) throws Exception { + + ServerSocket dataReceive = new ServerSocket(4444); + + while(true) { + Socket connectionSocket = dataReceive.accept(); + Thr t=new Thr(connectionSocket); + t.start(); + } + } +} \ No newline at end of file diff --git a/TopologicalSorting.java b/TopologicalSorting.java new file mode 100644 index 0000000..ec85870 --- /dev/null +++ b/TopologicalSorting.java @@ -0,0 +1,53 @@ +import java.util.*; +class Graph{ + int v; + LinkedList adj[]; + @SuppressWarnings("unchecked") + Graph(int v){ + this.v=v; + adj=new LinkedList[v]; + for(int i=0;i(); + } +} +class TopologicalSorting{ + public static void addEdge(Graph g,int u,int v){ + g.adj[u].add(v); + } + public static void toposortutil(Graph g,int node,boolean visit[],Stack st) + { + visit[node]=true; + int i; + Iteratorit=g.adj[node].iterator(); + while(it.hasNext()) + { + i=it.next(); + System.out.println(i); + if(!visit[i]) + toposortutil(g,i,visit,st); + } + System.out.println("node"+node); + st.push(node); + } + public static void toposort(Graph g){ + Stack st=new Stack(); + boolean visit[]=new boolean[g.v]; + for(int i=0;i new-branch) +Author: itsEobard2025 +Date: Sun Oct 31 09:48:15 2021 +0530 + + Added a new haiku in poetry.md file + +commit 9c663b4be4581f3c02c4a68dc20c44d493b2df65 (origin/main, origin/HEAD, main) +Merge: ffb996d 878130b +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sat Oct 30 16:30:56 2021 +0530 + + Merge pull request #109 from Assassin-compiler/main + + Create CircularLinkedlist.cpp + +commit 878130bccdc35d6549fa73dea2f2a1deb891f4b2 +Author: Assassin-compiler <70448612+Assassin-compiler@users.noreply.github.com> +Date: Sat Oct 30 16:29:15 2021 +0530 + + Create CircularLinkedlist.cpp + +commit ffb996d0d465df6275b1bb9e2279ed954ef2e01a +Merge: 511fcd9 6be6ee7 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sat Oct 30 12:23:03 2021 +0530 + + Merge pull request #108 from Assassin-compiler/main + + Create Subarrays.cpp + +commit 6be6ee7cb936fb2d7a1be3636f7e2b31583e3cb5 +Author: Assassin-compiler <70448612+Assassin-compiler@users.noreply.github.com> +Date: Sat Oct 30 12:22:03 2021 +0530 + + Create Subarrays.cpp + +commit 511fcd9e697955621b65b8a7e695c6156866fa9d +Merge: a589f14 6a00544 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sat Oct 30 12:16:11 2021 +0530 + + Merge pull request #107 from Assassin-compiler/main + + Create range.cpp + +commit 6a00544099f04f160fd08bc62ab3f44446bead32 +Author: Assassin-compiler <70448612+Assassin-compiler@users.noreply.github.com> +Date: Sat Oct 30 12:15:14 2021 +0530 + + Create range.cpp + +commit a589f14669a4d5b7a495e9c84be563dbe9a25242 +Merge: bfe9e75 83bed70 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sat Oct 30 12:13:38 2021 +0530 + + Merge pull request #106 from Assassin-compiler/main + + Create triplets.cpp + +commit 83bed704d970691e6d3a3b646d004e0a5a64eac2 +Author: Assassin-compiler <70448612+Assassin-compiler@users.noreply.github.com> +Date: Sat Oct 30 12:12:21 2021 +0530 + + Create triplets.cpp + +commit bfe9e757f9373c1aa635f39ee0a51816e3213349 +Merge: 23534ff f8a975a +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sat Oct 30 03:07:26 2021 +0530 + + Merge pull request #105 from PandaWire/main + + Create PalindromicNumber.java + +commit 23534ff0374796be783ac08599447ae4f242f7cb +Merge: 34483e9 473c349 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sat Oct 30 03:07:03 2021 +0530 + + Merge pull request #104 from rajniarora26/patch-3 + + Add PrimsAlgo.java + +commit f8a975a858c47ebbe9f7cceff1cc54b9145066d0 +Author: Andrew Pai <88261387+PandaWire@users.noreply.github.com> +Date: Fri Oct 29 13:38:25 2021 -0700 + + Create PalindromicNumber.java + +commit 473c3499d6cde3f024c0e734d17c9fa8b092e85e +Author: rajniarora26 <72189047+rajniarora26@users.noreply.github.com> +Date: Sat Oct 30 00:43:01 2021 +0530 + + Add PrimsAlgo.java + + Program for Prim's Algorithm + +commit 34483e957905d2a019c24eb41e2142ae611107a2 +Merge: e8f7b40 7a0f2dc +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Fri Oct 29 23:47:20 2021 +0530 + + Merge pull request #103 from madhav1928/main + + Add files via upload + +commit e8f7b4026d4e34237aad7547c41a3f494c54524f +Merge: 74e2b76 866c836 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Fri Oct 29 23:47:00 2021 +0530 + + Merge pull request #102 from rajniarora26/patch-1 + + Add BottomView.java + +commit 74e2b76d2d5312b4fbc533a23f85ed109dbadff2 +Merge: bab03be ef5cc63 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Fri Oct 29 23:46:36 2021 +0530 + + Merge pull request #101 from Anuragjain20/arj + + added diamond pattern program + +commit 7a0f2dc6cd68685a02c852b38ce96ce9faf9a0d5 +Author: Madhav <56249178+madhav1928@users.noreply.github.com> +Date: Fri Oct 29 23:29:21 2021 +0530 + + Add files via upload + +commit 866c836c2953e741cdea622dbba2111401ebc229 +Author: rajniarora26 <72189047+rajniarora26@users.noreply.github.com> +Date: Fri Oct 29 22:05:14 2021 +0530 + + Add BottomView.java + + Program to print bottom view of a binary tree. + +commit ef5cc639b6f2fc7d63a2dba8d20f3fba1f454db7 +Author: Anurag +Date: Fri Oct 29 21:40:22 2021 +0530 + + added diamond pattern program + +commit bab03be437a57295cd8783042c83b39b64929e1d +Merge: 281731e 3b451f1 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Fri Oct 29 12:44:27 2021 +0530 + + Merge pull request #100 from lkmSasanga/main + + search an element in a Circular Linked List + +commit 281731ed1f792c92db12302a73151ebe1bcc500e +Merge: 7ab36d3 a49ba75 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Fri Oct 29 12:44:04 2021 +0530 + + Merge pull request #99 from neetukhanna11/patch-1 + + Committing BinaryTree.java + +commit 3b451f1f026658d30d29e76049ba51f63826ed72 +Author: Malindu Sasanga +Date: Fri Oct 29 12:35:06 2021 +0530 + + search an element in a Circular Linked List + + Java program to search an element in a Circular Linked List + +commit a49ba759096e0f892ff8769861f6cf51ef21d341 +Author: neetukhanna11 <72187682+neetukhanna11@users.noreply.github.com> +Date: Fri Oct 29 10:32:03 2021 +0530 + + Committing BinaryTree.java + + Program to print Top View of a Binary Tree + +commit 7ab36d332e5abc2a7c75255449cc44cace31fc51 +Merge: 2dbd83c f995a04 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Fri Oct 29 01:50:57 2021 +0530 + + Merge pull request #98 from jhanna60/main + + Adding a heapsort algorithm + +commit f995a04241410e1a5e72289700ec5aa6b2e4420a +Author: john hanna +Date: Thu Oct 28 19:07:34 2021 +0100 + + Adding a heapsort algorithm + +commit 2dbd83c8470f8761e373d96cda28747ad286fef3 +Merge: a0a0d34 acfbaad +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 28 23:26:17 2021 +0530 + + Merge pull request #95 from Nehansh10/dev + + Last Digit of Fibonnaci + +commit a0a0d34200e7300839f2854bf2d20d3cb31ec92c +Merge: e40589c 56aa950 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 28 23:25:55 2021 +0530 + + Merge pull request #96 from eby8zevin/patch-1 + + Create Searching.java + +commit e40589cd2a6acd38eb5675c0493eb5cdc3b27e4c +Merge: 540e2da 5b61e7f +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 28 23:25:25 2021 +0530 + + Merge pull request #97 from vanditkhurana1/patch-1 + + Committing SpiralMatrix.java + +commit 5b61e7fce61e8d50ad58ef04f36ba48cd6a7af5a +Author: vanditkhurana1 <92248205+vanditkhurana1@users.noreply.github.com> +Date: Thu Oct 28 21:24:33 2021 +0530 + + Committing SpiralMatrix.java + +commit 56aa9502992c6897a279d3ee9a627a7e07070f07 +Author: احمد ابو حسن <36786100+eby8zevin@users.noreply.github.com> +Date: Thu Oct 28 22:33:34 2021 +0700 + + Create Searching.java + +commit acfbaada5d4dc415623a106dbba22cec8099dfd6 +Author: Nehansh10 +Date: Thu Oct 28 20:55:21 2021 +0530 + + Last Digit of Fibonnaci + +commit 540e2dabbbfb2eae37b5603abd737dc73e686693 +Merge: 9fbc959 e97cdb2 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 28 20:41:20 2021 +0530 + + Merge pull request #94 from eby8zevin/main + + Create Calculator.java + +commit 9fbc9594a7873b1e1d4e2f8c54dd6f89c85397d1 +Merge: ddc8a74 08f6b22 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 28 20:40:56 2021 +0530 + + Merge pull request #93 from harshalkh/patch-1 + + Create BucketSort.java + +commit e97cdb2be169f89d4a8d970b1b692f2a7cd80f71 +Author: احمد ابو حسن <36786100+eby8zevin@users.noreply.github.com> +Date: Thu Oct 28 22:02:38 2021 +0700 + + Create Calculator.java + +commit 08f6b22411857448fde28f89e37666944234f2de +Author: Harshal <37841724+harshalkh@users.noreply.github.com> +Date: Thu Oct 28 19:49:44 2021 +0530 + + Create BucketSort.java + + Bucket sort in java + +commit ddc8a74563b899e7f184d5209065ff16c87022a6 +Merge: 106167e 4ec4a02 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 28 18:35:31 2021 +0530 + + Merge pull request #92 from gandharva-gk/main + + Binary Search + +commit 4ec4a024456e16dcaa08404576f852bba6caa60f +Author: gandharva +Date: Thu Oct 28 18:30:36 2021 +0530 + + Binary Search + +commit 106167eb722f4ca832d3e0a660ddc2aff875818d +Merge: ba394c0 58a2cc4 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 28 18:01:21 2021 +0530 + + Merge pull request #91 from gandharva-gk/main + + Merge Two Sorted Lists + +commit 58a2cc462c2158090ae475013f7ee3b736668a13 +Author: gandharva +Date: Thu Oct 28 17:36:39 2021 +0530 + + Merge Two Sorted Lists + +commit ba394c09842a23e8214dd7bf7003018faf363127 +Merge: 0adf103 5ae4bc9 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 28 13:30:04 2021 +0530 + + Merge pull request #90 from andikscript/main + + add data structure graphs FloydWarshall + +commit 5ae4bc9e8e66decbeb3b1d88b89d89868d7a6574 +Author: andikscript +Date: Thu Oct 28 13:51:26 2021 +0700 + + add data structure graphs FloydWarshall + +commit 0adf103da1120faac8c3b8bbe1aab2d08f614a26 +Merge: f25a5c6 1e745d3 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 28 12:12:32 2021 +0530 + + Merge pull request #89 from andikscript/main + + add algorithm cipher RSA + +commit 1e745d34732e0bd4f9301de76136dd20f2edbebe +Author: andikscript +Date: Thu Oct 28 13:32:55 2021 +0700 + + add algorithm cipher RSA + +commit f25a5c673ee2f30be441fa8e47c9cc1ee32827ee +Merge: 1949140 06d7e06 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 28 11:49:42 2021 +0530 + + Merge pull request #88 from dayagct/main + + Catalan number upload + +commit 1949140dd3e7dac65d144c9affc70e32a30bb05c +Merge: 91d8380 02405ee +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 28 11:48:48 2021 +0530 + + Merge pull request #87 from andikscript/main + + add algorithm radix sort + +commit 91d8380718ef2e9ab5658e98bb5c0d5756dca035 +Merge: 9614a19 6cd486e +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 28 11:43:01 2021 +0530 + + Merge pull request #86 from ShreyasAnish/main + + Create TrafficLight.java + +commit 9614a19d736c6e870a35ab8350d48fbfa774b935 +Merge: 673b959 081b3ed +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 28 11:42:36 2021 +0530 + + Merge pull request #85 from SahanChan/main + + hacktoberfest2021SahanChan + +commit 673b9595bcd1d3fb347b53c1a7a4753d827fddec +Merge: 712e924 050a5c1 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 28 11:42:08 2021 +0530 + + Merge pull request #84 from vanditkhurana/patch-1 + + Committing KadanesAlgo.java + +commit 06d7e0636b0e5985b2c0d0f5ee1417806d4630e8 +Author: dayagct <91879871+dayagct@users.noreply.github.com> +Date: Thu Oct 28 09:19:09 2021 +0530 + + Add files via upload + + Added Java program for Catalan numbers + +commit 02405eee192c84befc28c6da082df21e4e514c5d +Author: andikscript +Date: Thu Oct 28 07:22:21 2021 +0700 + + add algorithm radix sort + +commit 6cd486ecdc49c18f9548106882ab88b8c5ebd755 +Author: ShreyasAnish <65059923+ShreyasAnish@users.noreply.github.com> +Date: Thu Oct 28 01:33:14 2021 +0530 + + Create TrafficLight.java + + A program to simulate the red, yellow and green lights in a traffic signal using Java Swing. + +commit 081b3ed7f99026a81dbbc3ab12b215dacc2dced0 +Author: Sahan Chan +Date: Wed Oct 27 23:02:45 2021 +0530 + + hacktoberfest2021SahanChan + +commit 050a5c1d6d6ce0304ab40aaf395f9f8eff6a0514 +Author: Vandit <52314194+vanditkhurana@users.noreply.github.com> +Date: Wed Oct 27 23:02:19 2021 +0530 + + Committing KadanesAlgo.java + +commit 712e92496fba3aa71a8f04e45b350d172e2beec5 +Merge: 4c27349 e79ed8d +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Wed Oct 27 22:52:18 2021 +0530 + + Merge pull request #82 from shubhamSM1298/main + + Circular Queue + +commit 4c27349c1a3f5bd2132bc7de5a90e1d69b1a171e +Merge: 639143e 70fc510 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Wed Oct 27 22:51:55 2021 +0530 + + Merge pull request #83 from prateekgargX/main + + RSA Algorithm in JAVA + +commit 70fc5109353852bc7894877391f9f7f24347be1e +Author: prateekgargX +Date: Wed Oct 27 20:14:41 2021 +0530 + + RSA Algorithm in JAVA + +commit e79ed8d527c8f7ef49abbc62ede882ae00fbb28d +Author: Shubham Mallya <91719093+shubhamSM1298@users.noreply.github.com> +Date: Tue Oct 26 11:20:36 2021 +0530 + + Circular Queue + + pls check it + +commit 639143e2cde653d4dca67b9c98f47949e29c73a3 +Merge: 2ef0b76 63b92ff +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Tue Oct 26 11:19:16 2021 +0530 + + Merge pull request #81 from AdityaRawat07/main + + Buzz.java + +commit 2ef0b76ac184d4128d2731e98eeb33358b254c31 +Merge: 0e66ad7 4e40329 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Tue Oct 26 11:18:57 2021 +0530 + + Merge pull request #80 from rnzit/patch-1 + + Create ReverseString.java + +commit 0e66ad7c39d6e69f202924b50a5a6357807660c6 +Merge: 4c18ea4 ef7bb7a +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Tue Oct 26 11:18:41 2021 +0530 + + Merge pull request #79 from ana-pat/patch-1 + + Kasturba.java + +commit 4c18ea415e87ee1f3b4653b8e86ee0849ca78f38 +Merge: 1ccc528 6d46cb9 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Tue Oct 26 11:18:00 2021 +0530 + + Merge pull request #78 from sahooankeeta/main + + added k equal sum subsets + +commit 1ccc528a378b46d5b52b3ab6f9900f4153a403ab +Merge: 9379b5a 0c0e1e3 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Tue Oct 26 11:17:35 2021 +0530 + + Merge pull request #77 from sanju2/main + + BogoSort.java Added + +commit 9379b5a67970609ef028cffc70494f936caad014 +Merge: 0ce32fd fe2f9ad +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Tue Oct 26 11:16:54 2021 +0530 + + Merge pull request #76 from anjupriya-v/main + + Anagram + +commit 0ce32fd97375a45297fa02ad07a5ef2f49c9b05e +Merge: ca35182 7b2def2 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Tue Oct 26 11:16:23 2021 +0530 + + Merge pull request #75 from Sachin-Liyanage/main + + Program for Tower of Hanoi + +commit ca35182cba403921f69c173839a169beff0cefe4 +Merge: 980a238 7af3552 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Tue Oct 26 11:16:03 2021 +0530 + + Merge pull request #74 from krittin1/main + + :sparkles: [feat]: add GuessingGame program + +commit 980a238f4f8145c48ee65d30fb7df6b77ab10e24 +Merge: 6b72837 4dde16c +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Tue Oct 26 11:15:35 2021 +0530 + + Merge pull request #73 from Yasas4D/main-oop-concepts + + Add main OOP concepts + +commit 6b72837b5114d88625e86c0e063155c5a32a1e24 +Merge: d9b8924 be8b463 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Tue Oct 26 11:14:45 2021 +0530 + + Merge pull request #72 from adithyarjndrn/main + + DECimal2Hexa + +commit 63b92ffe6aedaaf7e9aba6f0092f7ae64862b506 +Author: AdityaRawat07 <92925758+AdityaRawat07@users.noreply.github.com> +Date: Mon Oct 25 22:25:38 2021 +0530 + + Buzz.java + +commit 4e40329c43407238d168412fc89e2cb277350889 +Author: rnzit <32677893+rnzit@users.noreply.github.com> +Date: Mon Oct 25 22:48:06 2021 +0700 + + Create ReverseString.java + +commit ef7bb7ac86d3dfc89f6ddb7b5df0e8f10a89c0a2 +Author: Ananya Pathak <54628162+ana-pat@users.noreply.github.com> +Date: Mon Oct 25 14:21:02 2021 +0530 + + Kasturba.java + + Implements Kasturba Algorithm for Matrix Multiplication + +commit 6d46cb9dd743859248e55379860f7fc712bea788 +Author: Ankeeta Sahoo +Date: Sun Oct 24 21:59:22 2021 +0530 + + added k equal sum subset + +commit 0c0e1e337a62d2210aa54cc4f5cb7cd1422cbe6d +Author: lasantha96 +Date: Sun Oct 24 21:54:09 2021 +0530 + + BogoSort.java Added + +commit f86c8b588ce1bfb44e21aaba7179b337b900b48b +Author: Ankeeta Sahoo +Date: Sun Oct 24 21:49:02 2021 +0530 + + added k equal sum subsets + +commit fe2f9ad0186185d82d4e4707040722ce180ffd03 +Author: Anju Priya V <84177086+anjupriya-v@users.noreply.github.com> +Date: Sun Oct 24 21:28:19 2021 +0530 + + Add files via upload + +commit 7b2def2196f913e33665ebbebf8acef850fbe152 +Author: Sachin Liyanage <59449070+Sachin-Liyanage@users.noreply.github.com> +Date: Sun Oct 24 21:10:13 2021 +0530 + + Program for Tower of Hanoi + +commit 7af35521ddef4c929770bb10d2b14a8aeb0c0554 +Author: Arty Kanok +Date: Sun Oct 24 18:15:23 2021 +0700 + + :sparkles: [feat]: add Hangman.java + +commit b676c29f699c3b387aa0de9ba50a6cb2b332b609 +Author: Arty Kanok +Date: Sun Oct 24 18:08:53 2021 +0700 + + :sparkles: [feat]: add WordMatch.java + +commit c7908ff590c59293e73e7b1a8de675284e7ab816 +Author: Arty Kanok +Date: Sun Oct 24 18:07:42 2021 +0700 + + :sparkles: [feat]: add GuessingGame program + +commit 4dde16c31025ff6127a100f9e2d22fc22412154a +Author: Yasas Sandeepa +Date: Sun Oct 24 12:39:37 2021 +0530 + + Add main OOP concepts + +commit be8b4635890f16e7ef26156fa1dcc107d8d1ed58 +Author: adithyarjndrn +Date: Sun Oct 24 05:41:21 2021 +0530 + + DECimal2Hexa + +commit d9b892440d9388667634e43e866b6f374d9330ba +Merge: e0d3cc0 fa97914 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Fri Oct 22 22:54:55 2021 +0530 + + Merge pull request #70 from gandharva-gk/main + + Djikstra Algorithm in Java + +commit fa97914321137081345834ab75096986683b01c0 +Author: gandharva +Date: Fri Oct 22 19:12:27 2021 +0530 + + Djikstra Algorithm in Java + +commit e0d3cc02ac6409c2dfb226e701bb24ab57094a3a +Merge: 0f2f250 a2208d4 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 21 20:16:57 2021 +0530 + + Merge pull request #69 from DushyanthaAT/main + + Fibonacci.java + +commit a2208d4c3f23daebc19596278991e7a2d281fdd9 +Author: Dushyantha Thilakarathne +Date: Thu Oct 21 17:07:45 2021 +0530 + + Fibonacci.java + + Updated this code to get user input and print Fibonacci series + +commit 0f2f25004b029d5144f7e44d87f2c55fa96ea331 +Merge: d3a9ff9 cd0d89f +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Thu Oct 21 08:23:13 2021 +0530 + + Merge pull request #68 from Amrutha26/main + + added java file + +commit cd0d89f3bf0bfc5b43c1c88cf9cb2d217e53e8e0 +Author: Amrutha <62595123+Amrutha26@users.noreply.github.com> +Date: Thu Oct 21 04:51:41 2021 +0530 + + added java file + +commit d3a9ff972ef4aa4d9f9a30243ca5eda1482758f2 +Merge: 89c336d f1d9371 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Wed Oct 20 22:31:54 2021 +0530 + + Merge pull request #66 from DushyanthaAT/main + + ReverseArray.java + +commit 89c336da7a484a5bbc64fcf1d703fc2a97920f08 +Merge: bda2033 45ac778 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Wed Oct 20 22:30:50 2021 +0530 + + Merge pull request #67 from Amrutha26/main + + added java file + +commit 45ac778db38eb9a6fcbd852b8f32bbcc1685e610 +Author: Amrutha <62595123+Amrutha26@users.noreply.github.com> +Date: Wed Oct 20 18:55:35 2021 +0530 + + added java file + +commit f1d9371e820d2cf42535b65aa112cb3f5d4d5fa1 +Author: Dushyantha Thilakarathne +Date: Wed Oct 20 13:55:11 2021 +0530 + + ReverseArray.java + + I have updated this code for saving the reversed array. + +commit bda2033ec2f8818d71e0279add11c63e3f22f27d +Merge: c2b980b f0a25ff +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Wed Oct 20 12:57:16 2021 +0530 + + Merge pull request #60 from skmodi649/Add-StackSorting.java + + Create StackSorting.java + +commit c2b980bea6ba65759ecd5b43631d2063f9fa8c27 +Merge: 3547cdb 7e7bf5e +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Wed Oct 20 12:56:44 2021 +0530 + + Merge pull request #61 from skmodi649/Add-DigitalRoot.java + + Create DigitalRoot.java + +commit 3547cdb0a35c1d7d797dc5094cc5c8edca68bed5 +Merge: 8a8b10f b30afe1 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Wed Oct 20 12:56:25 2021 +0530 + + Merge pull request #62 from kashishahuja2002/Kashish + + KBC quiz + +commit 8a8b10f8f70c294ac67e2d974db91871fc1b9897 +Merge: 492e182 ddb9efa +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Wed Oct 20 12:56:04 2021 +0530 + + Merge pull request #63 from Amrutha26/main + + Rotated Binary Search + +commit 492e182c8db10f383b51da215a2916896ea80433 +Merge: 27e2a03 538851e +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Wed Oct 20 12:55:44 2021 +0530 + + Merge pull request #65 from DiSousaDev/java_readme + + Java readme + +commit 538851e1cb306419319f92f40dc6a8d0e0497de8 +Author: Eder Diego de Sousa +Date: Tue Oct 19 14:51:39 2021 -0300 + + Add readme + +commit 063b9da1a8af8b23785356f5d4017f932159a0e0 +Author: Eder Diego de Sousa +Date: Tue Oct 19 14:35:51 2021 -0300 + + Add an ArrayListString example + +commit ddb9efaf474dc5b1708db2b1a68f5c32671f9b3a +Author: Amrutha <62595123+Amrutha26@users.noreply.github.com> +Date: Mon Oct 18 18:46:23 2021 +0530 + + added java file + +commit 0ed87b0ab70fabbe9ac22303520677a183ca6022 +Author: Amrutha <62595123+Amrutha26@users.noreply.github.com> +Date: Mon Oct 18 18:40:10 2021 +0530 + + added java file + +commit b30afe1db92c262c20abe0e150801789f33ff563 +Author: Kashish Ahuja +Date: Mon Oct 18 18:10:13 2021 +0530 + + KBC quiz + +commit 7e7bf5ea3ffae30c759c8741f135672c2c32d3d1 +Author: Suraj Kumar Modi <76468931+skmodi649@users.noreply.github.com> +Date: Sun Oct 17 20:14:51 2021 +0530 + + Create DigitalRoot.java + +commit f0a25ff51e4444b2b305bee1d56c47522f10106a +Author: Suraj Kumar Modi <76468931+skmodi649@users.noreply.github.com> +Date: Sun Oct 17 20:03:18 2021 +0530 + + Create StackSorting.java + +commit 27e2a03a332d295b6c9f1c6c64793b6f4c2e5ae1 +Merge: 9d994cb 7486547 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 17 15:20:53 2021 +0530 + + Merge pull request #59 from runtime-error2905/main + + Created Matrix Multiplication java file + +commit 74865471c35706ba881fbb228a498e52cff7a889 +Author: SAURABH KUMAR <86124127+runtime-error2905@users.noreply.github.com> +Date: Sun Oct 17 15:14:14 2021 +0530 + + Created Matrix Multiplication java file + + Implementation of Matrix Multiplication + +commit 9d994cb1183aaeae25aa39343fb2243ee76d47ab +Merge: 6480868 ae90ff0 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 17 03:46:37 2021 +0530 + + Merge pull request #54 from vipu18/main + + Create java_database_connectivity.java + +commit 64808683696d5407186d5481201d85484f28afc0 +Merge: d24f775 e7df62c +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 17 03:46:15 2021 +0530 + + Merge pull request #53 from krishnapalS/patch-2 + + Create BST.java + +commit d24f7759aaf1ef6670a4529fc6e4ce0eae551400 +Merge: 6353c4b 48c08c6 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 17 03:45:44 2021 +0530 + + Merge pull request #52 from khushi200701/pr2 + + climbing-stairs-leetcode + +commit 6353c4b0c4d007de86a599a5694d63613b614589 +Merge: 2418c57 a09f97c +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 17 03:45:17 2021 +0530 + + Merge pull request #51 from Priya-shan/main + + Added 3 Programs - Breakdigit, ReverseArray, RandomNumberGenerator + +commit 2418c5794d11007ffe0006d755bdcf5f2ac7cf41 +Merge: af0ea0d 3f35faf +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 17 03:44:49 2021 +0530 + + Merge pull request #50 from nawodyaonline/main + + ArrayList iteration ways + +commit af0ea0de41ecf6e839d19851833cc4eeae727cfe +Merge: f0b6e7a 02f48ce +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 17 03:44:27 2021 +0530 + + Merge pull request #49 from AbhinandanAdhikari/Java-Factorial + + JAVA Program to Calculate Factorial of a Number + +commit f0b6e7ad30dc0dfdab612d079639d92929cdb7e9 +Merge: 0c8c846 bc10764 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 17 03:43:59 2021 +0530 + + Merge pull request #48 from harsh827/main + + Hash-Table-In-Java + +commit 0c8c8469f84c3783a6b51179912ef8762ac6be54 +Merge: e145051 2b25423 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 17 03:43:30 2021 +0530 + + Merge pull request #47 from hitesh181/main + + Added java program to convert string to lower case + +commit e14505181431a5306dda9fa8cd25e9ff525c9d8b +Merge: 3183266 2b5d76d +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 17 03:43:05 2021 +0530 + + Merge pull request #55 from JayNakum/main + + Adding programs of JavaApplets + +commit 31832669b94b7e243abb8f31d24d49dd97ca0e9e +Merge: 39b3342 bd7b643 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 17 03:42:35 2021 +0530 + + Merge pull request #56 from Omkar0114/main + + Create sqrt.java + +commit 39b33423e913352cd4f8c7b5ff9cf870b8503611 +Merge: bd1743c 9db8388 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 17 03:42:05 2021 +0530 + + Merge pull request #57 from DasuniMaheshika/main + + Create GreatestCommonDivisor.java + +commit 9db83887461410bbc7472218737e4ad2d02da8e6 +Author: Dasuni Udugama Sooriyage <58808249+DasuniMaheshika@users.noreply.github.com> +Date: Fri Oct 15 22:59:45 2021 +0530 + + Create GreatestCommonDivisor.java + + Finding Greatest Common Divisor using Java + +commit bd7b6431ed65dae507f0594d8f3621b3f51cb200 +Author: Omkar kulkarni <88308267+Omkar0114@users.noreply.github.com> +Date: Fri Oct 15 17:49:39 2021 +0530 + + Create sqrt.java + +commit 2b5d76d44d4dc7c7fe2360c8e5f30be6db39889a +Author: Jay Nakum +Date: Fri Oct 15 16:46:24 2021 +0530 + + Added an example program of AWT Elements and behaviour + +commit b68f7d643b85b0d178a420c436cd4ffe2d5674d1 +Author: Jay Nakum +Date: Thu Oct 14 09:50:42 2021 +0530 + + Added basic programs of JavaApplets + +commit ae90ff06e0133c65e2dc678fb9f1f464ae4cc6a8 +Author: Vipanshu Suman <73050057+vipu18@users.noreply.github.com> +Date: Wed Oct 13 19:50:50 2021 +0530 + + Create java_database_connectivity.java + +commit bd1743cb567ef0b0821738cdf8bd5855d522ebdd +Merge: 56f1568 4a640b0 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Wed Oct 13 10:02:47 2021 +0530 + + Merge pull request #46 from tushar152/main + + Create amstrongNumber.java + +commit e7df62c19ef4611f77a138e20f961d4e0389c101 +Author: Krishna Pal Deora <47516664+krishnapalS@users.noreply.github.com> +Date: Tue Oct 12 22:04:56 2021 +0530 + + Create BST.java + +commit 48c08c6f52cf167c750ad34ae8d2867d485a68d4 +Author: Khushi <58480229+khushi200701@users.noreply.github.com> +Date: Tue Oct 12 11:08:16 2021 +0530 + + climbing-stairs-leetcode + +commit a09f97c10f05dea8560aca12f3c561163cbfe570 +Author: Shanmuga Priya M <67195594+Priya-shan@users.noreply.github.com> +Date: Tue Oct 12 03:42:30 2021 +0530 + + Create ReverseArray.java + +commit 98c8bcc0c55bd055808e94150effa76e78e8cbef +Author: Shanmuga Priya M <67195594+Priya-shan@users.noreply.github.com> +Date: Tue Oct 12 03:41:39 2021 +0530 + + Create RandomNumber.java + +commit 0da1876a8228281be330440df8c223c16c85f33c +Author: Shanmuga Priya M <67195594+Priya-shan@users.noreply.github.com> +Date: Tue Oct 12 03:40:44 2021 +0530 + + Create BreakDigit.java + +commit 3f35fafae45d7b28ab6cbb999a59979b6386d633 +Author: Nawodya Jayalath +Date: Mon Oct 11 22:02:46 2021 +0530 + + ArrayList iteration ways + +commit 02f48ce48f3d7421f35fcfc743eca2dcd334f98d +Author: Abhinandan Adhikari +Date: Mon Oct 11 21:46:38 2021 +0530 + + Added Java Program to find Factorial + +commit bc107643ecc60643596c7a7ce250cc22398bbe20 +Author: Harsh Kumar <73309402+harsh827@users.noreply.github.com> +Date: Mon Oct 11 21:07:02 2021 +0530 + + Create knight__tour.java + +commit 989620e46ef9002044ebc70b312606248d05dea0 +Author: Harsh Kumar <73309402+harsh827@users.noreply.github.com> +Date: Mon Oct 11 21:00:44 2021 +0530 + + Rename hash_table_implementation.java to hash_table_code.java + +commit 66cf8d914a4adaa25d0ded1980a8d95a250c7886 +Author: Harsh Kumar <73309402+harsh827@users.noreply.github.com> +Date: Mon Oct 11 20:58:23 2021 +0530 + + Hash-Table-In-Java + + Implementation of hash table in java + +commit 2b2542376046302d0bfbb5b448cdea526dbd47c3 +Author: Hitesh Sharma <68909492+hitesh181@users.noreply.github.com> +Date: Sun Oct 10 00:25:07 2021 +0530 + + Added java program to convert string to lower case + +commit 4a640b018e3a66d5b91488c68055d576d4838b47 +Author: Tushar Garg <61476389+tushar152@users.noreply.github.com> +Date: Sat Oct 9 02:45:45 2021 +0530 + + Update ShellSort.java + +commit e4fba59f8bb18b0068f7f05cf7d60cbc9eadca33 +Author: Tushar Garg <61476389+tushar152@users.noreply.github.com> +Date: Sat Oct 9 02:43:27 2021 +0530 + + Update QuickSort.java + +commit 0f3bfc6479917a99c95beb9ae6c58f02b8eb4cba +Author: Tushar Garg <61476389+tushar152@users.noreply.github.com> +Date: Sat Oct 9 02:39:45 2021 +0530 + + Update Echo.java + +commit d2a0d1de9338084467a0f6432d78a56f9e579b64 +Author: Tushar Garg <61476389+tushar152@users.noreply.github.com> +Date: Sat Oct 9 02:38:10 2021 +0530 + + Update Harry.java + +commit 90c990d416cb172c81abbe6a1f78364227504f39 +Author: Tushar Garg <61476389+tushar152@users.noreply.github.com> +Date: Sat Oct 9 02:36:54 2021 +0530 + + Update Fibonacci.java + +commit d681b531664de96311acc8ec929290124e4dde0f +Author: Tushar Garg <61476389+tushar152@users.noreply.github.com> +Date: Sat Oct 9 02:32:49 2021 +0530 + + Update BubbleSort.java + +commit c4c33de312bc64624aa399a5055b0e1f1d0de292 +Author: Tushar Garg <61476389+tushar152@users.noreply.github.com> +Date: Sat Oct 9 02:30:40 2021 +0530 + + Create armstrongNumber.java + +commit 56f1568082bc3a7cee1c1973b1669734c5232c20 +Merge: 272b0de 63076ca +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sat Oct 9 00:50:02 2021 +0530 + + Merge pull request #45 from hitesh181/main + + Adding java program for Number Diamond pattern + +commit 63076cac6f70b6644f3bfeb83a727fec57d35acb +Author: Hitesh Sharma <68909492+hitesh181@users.noreply.github.com> +Date: Sat Oct 9 00:48:43 2021 +0530 + + Adding java program for Number Diamond pattern + +commit 272b0de7fe136935eff1c734c847bb50d00c67c0 +Merge: c3cbdc8 28f5a86 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Tue Oct 5 23:33:22 2021 +0530 + + Merge pull request #43 from AbhinandanAdhikari/java-prime + + Java Program to Check whether the Number is Prime or Not. + +commit 28f5a867f76d741aa0f30cbf50c58b9ee8ab4d58 +Author: Abhinandan Adhikari +Date: Tue Oct 5 21:37:10 2021 +0530 + + Java code for Prime Number + +commit c3cbdc81e7e8cdfe29026c62a0d2b3ad30d04672 +Merge: df90af7 d8eeed0 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 19:41:50 2021 +0530 + + Merge pull request #42 from Saurabh2509/main + + Stack java + +commit df90af71ecf8ce34a11a1b80ab827b35c9264a4e +Merge: 2deb06c d8ad866 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 19:41:31 2021 +0530 + + Merge pull request #41 from abhijeet49/main + + Added MultiClassDemo.java file + +commit d8eeed0ce24ef7fc8e9981bf88ed84959326ce17 +Author: Saurabh Kumar <54509629+Saurabh2509@users.noreply.github.com> +Date: Mon Oct 4 19:40:55 2021 +0530 + + Stack java + + Implementation Stack java + +commit 2deb06c045307fbdb7e92b4bf38234b234c0a62c +Merge: af7068c ae5f2a4 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 19:39:24 2021 +0530 + + Merge pull request #40 from Saurabh2509/main + + Vector.java + +commit d8ad86677256958329673336846f60f3ec0865d1 +Author: Abhijeet Kumar Ghosh <60868332+abhijeet49@users.noreply.github.com> +Date: Mon Oct 4 19:38:21 2021 +0530 + + Add files via upload + +commit ae5f2a458fe1047fae2920db41b414ad693be5e2 +Author: Saurabh Kumar <54509629+Saurabh2509@users.noreply.github.com> +Date: Mon Oct 4 19:36:52 2021 +0530 + + Vector.java + + Vector Implementation + +commit af7068ca434479e214cacb0798b39371ec65f974 +Merge: 542c967 748f139 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 19:34:53 2021 +0530 + + Merge pull request #39 from Saurabh2509/main + + ArrayList.java + +commit 748f139303a8d6a80d9fecb5863ae4376c5e836c +Author: Saurabh Kumar <54509629+Saurabh2509@users.noreply.github.com> +Date: Mon Oct 4 19:34:11 2021 +0530 + + ArrayList.java + + Arraylist.java Added + +commit 542c967710ed7d5f0ae8f6feb1b61a0089aaa149 +Merge: eaac131 6ae4418 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 19:28:37 2021 +0530 + + Merge pull request #38 from Saurabh2509/main + + Added Linkedlistdeque.java + +commit 6ae4418eba750d92db1cd118331aa68861834c25 +Author: Saurabh Kumar <54509629+Saurabh2509@users.noreply.github.com> +Date: Mon Oct 4 19:26:49 2021 +0530 + + Added Linkedlistdeque.java + +commit eaac131784e1150c82a03fbc7d99853e6f225a94 +Merge: 5dedb79 2101153 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 19:24:30 2021 +0530 + + Merge pull request #37 from Saurabh2509/main + + Add files via upload + +commit 2101153ddf1238230e44eb5d1e7ff20df274b71f +Author: Saurabh Kumar <54509629+Saurabh2509@users.noreply.github.com> +Date: Mon Oct 4 19:22:58 2021 +0530 + + Add files via upload + +commit 5dedb79662c550c22ede932516e87c68539598da +Merge: 0b6fe20 3d09c77 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 18:16:06 2021 +0530 + + Merge pull request #36 from aarush2410/main + + isbn + +commit 3d09c778b275b8d637524571765eab9719a18b36 +Author: aarush2410 <76821730+aarush2410@users.noreply.github.com> +Date: Mon Oct 4 18:15:32 2021 +0530 + + isbn + +commit 0b6fe20b4dbfff4823e7df22282b8a629878eba6 +Merge: 9dda5aa 16722e2 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 18:15:24 2021 +0530 + + Merge pull request #35 from VinayKumar1512/main + + Print Maze Paths + +commit 9dda5aa47a02c57e9bd7678470b6db69dc4f39d8 +Merge: 387313e 7513bb0 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 18:12:22 2021 +0530 + + Merge pull request #34 from aarush2410/main + + sunny + +commit 7513bb082df6ff03139c5d7f7c525f6c9fd0bf91 +Author: aarush2410 <76821730+aarush2410@users.noreply.github.com> +Date: Mon Oct 4 18:11:54 2021 +0530 + + evil + +commit 7e092492a1a34460aafd74bc920e618ea73665a8 +Author: aarush2410 <76821730+aarush2410@users.noreply.github.com> +Date: Mon Oct 4 18:11:00 2021 +0530 + + evil + +commit 16722e2c33910e4b06b4820101a4ba79692488a1 +Author: Vinay Kumar <79040443+VinayKumar1512@users.noreply.github.com> +Date: Mon Oct 4 18:10:02 2021 +0530 + + Add files via upload + +commit 72fc3c67ec4d4782bf95ab485e58c6a8f013cca2 +Author: aarush2410 <76821730+aarush2410@users.noreply.github.com> +Date: Mon Oct 4 18:09:11 2021 +0530 + + sunny + +commit 387313ee164367f2b376d825e914f7cdc0576680 +Merge: a12b2f3 cf3ead0 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 18:07:36 2021 +0530 + + Merge pull request #33 from aarush2410/main + + left triangle + +commit cf3ead07bcbe67f303f465593d7036a27aa2596c +Author: aarush2410 <76821730+aarush2410@users.noreply.github.com> +Date: Mon Oct 4 18:07:13 2021 +0530 + + ascii + +commit 1061f922e5e0eedaa51e2c774055b65c3394723b +Author: aarush2410 <76821730+aarush2410@users.noreply.github.com> +Date: Mon Oct 4 18:05:32 2021 +0530 + + left triangle + +commit a12b2f3edb00303f376582ab5afa54945d47e2a4 +Merge: 589a725 076e8bb +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 18:04:30 2021 +0530 + + Merge pull request #32 from aarush2410/main + + jdbc java + +commit 589a725473f49c01199799a1426d92aa1670bb8a +Merge: 5213ecc 4b20b7b +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 18:03:56 2021 +0530 + + Merge pull request #30 from bodhiaditya/main + + Binary Tree Traversals. + +commit 076e8bb729d1c6b3b6b4d4785b397b5c7ae2f781 +Author: aarush2410 <76821730+aarush2410@users.noreply.github.com> +Date: Mon Oct 4 18:03:39 2021 +0530 + + jdbc java + +commit 5213eccaddeba851daeb7c3f613bf2510ba183d5 +Merge: 02ba74f 2df327d +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 18:03:31 2021 +0530 + + Merge pull request #31 from aarush2410/main + + Fibonnaci program + +commit 2df327d03a90f566af40e4c168e42cb31a34635c +Author: aarush2410 <76821730+aarush2410@users.noreply.github.com> +Date: Mon Oct 4 18:01:10 2021 +0530 + + Fibonnaci program + +commit 4b20b7baa300e1ff9cb92f2b100487071a61c62a +Author: Aditya +Date: Mon Oct 4 12:56:18 2021 +0530 + + BinaryTree Traversals. + +commit 02ba74f06004791c9e1bd82663636a26b20d6320 +Merge: 229a794 41ca5cb +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 12:36:08 2021 +0530 + + Merge pull request #29 from abhijeet49/main + + Added evenodd.java file + +commit 229a7946abdd6fda23375d2575b14403858f4a0a +Merge: fcf207b b4612f6 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 12:35:03 2021 +0530 + + Merge pull request #28 from vaibhavss08/main + + Create InsertionSort.java + +commit 41ca5cb0abb74e0679a8d05cfdcfd2dc67b0dc51 +Author: Abhijeet Kumar Ghosh <60868332+abhijeet49@users.noreply.github.com> +Date: Mon Oct 4 12:34:51 2021 +0530 + + Add files via upload + +commit b4612f631ba24f32316dddec5934b09d35b1eb2c +Author: vaibhavss08 <81666621+vaibhavss08@users.noreply.github.com> +Date: Mon Oct 4 12:32:29 2021 +0530 + + Create InsertionSort.java + +commit fcf207b19c5f06f289c2435a5229f4300cf42e9c +Merge: 5c156e4 db052ac +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 12:30:06 2021 +0530 + + Merge pull request #27 from abhijeet49/main + + Added SegmentTreeRMQ.java file + +commit db052acd79db569dac99fe8258f4337e19d1a02e +Author: Abhijeet Kumar Ghosh <60868332+abhijeet49@users.noreply.github.com> +Date: Mon Oct 4 12:28:37 2021 +0530 + + Added SegmentTreeRMQ.java file + +commit 5c156e46e4acbebfde1d88c17b76b25a6171673b +Merge: 2c4cf5c 6f4bba2 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 12:24:47 2021 +0530 + + Merge pull request #26 from shivu2806/main + + added priorityQueue.java + +commit 6f4bba2515d7a4a81fc42c012b038d2315f8d6e7 +Author: shivu2806 <91802335+shivu2806@users.noreply.github.com> +Date: Mon Oct 4 12:23:50 2021 +0530 + + initial commit + +commit 2c4cf5c983f9a56180818a028afd5ca664753cd3 +Merge: 1d21e56 b032dd9 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 01:00:54 2021 +0530 + + Merge pull request #23 from Zaman3027/Mahafuz + + added mergesort + +commit 1d21e56579ce12d90f965af757a608e17db3e983 +Merge: 2fe4d59 5df51a4 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 01:00:31 2021 +0530 + + Merge pull request #24 from TharinduK97/addpro + + Day time server + +commit 2fe4d59efdfd89d70322da4c752cb370b4d39faa +Merge: 70f42f6 19fc6b7 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Mon Oct 4 01:00:10 2021 +0530 + + Merge pull request #25 from abhijeet49/main + + Added Frequency.java file + +commit 19fc6b7267e44f9c9e04564f9184bb089526d1e1 +Author: Abhijeet Kumar Ghosh <60868332+abhijeet49@users.noreply.github.com> +Date: Mon Oct 4 00:58:12 2021 +0530 + + Added Frequency.java file + +commit 5df51a4a50425241e70b2b739cba2967376925aa +Author: Tharindu Kumarasinghe <57245404+TharinduK97@users.noreply.github.com> +Date: Sun Oct 3 23:40:05 2021 +0530 + + Day time server + +commit b032dd91c016b6730eda28e2ac9e01a4b8db8c97 +Author: Zaman3027 +Date: Sun Oct 3 22:43:12 2021 +0530 + + added mergesort + +commit 70f42f6dcf67b7ca6ae429deb3e76b900898696b +Merge: c2a26a9 20b02a3 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 22:29:11 2021 +0530 + + Merge pull request #22 from Ayush167/main + + Sample4.java + +commit 20b02a3abcacebc34104e6167b6f9211c07a1cf6 +Author: Ayush167 <57669505+Ayush167@users.noreply.github.com> +Date: Sun Oct 3 22:27:11 2021 +0530 + + Add files via upload + +commit c2a26a9704d0eb68b584fc53c510fb3fac3ed254 +Merge: b3821e1 23ccdca +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 22:26:34 2021 +0530 + + Merge pull request #21 from Ayush167/main + + Sample3.java + +commit 23ccdca903cbc84665b2663498ea4dcc4ccacdb1 +Author: Ayush167 <57669505+Ayush167@users.noreply.github.com> +Date: Sun Oct 3 22:25:11 2021 +0530 + + Add files via upload + +commit 1ff36d20ffeb94fe8ecb295deeb0b18caf868670 +Author: Ayush167 <57669505+Ayush167@users.noreply.github.com> +Date: Sun Oct 3 22:24:32 2021 +0530 + + Add files via upload + +commit b3821e1a7c892324aff8d97d61e20626e1ba9aec +Merge: 97239c7 00ebf9f +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 22:23:42 2021 +0530 + + Merge pull request #20 from Ayush167/main + + Sample2.java + +commit 00ebf9fd67e373f43069815f2af42ec7cdef8604 +Author: Ayush167 <57669505+Ayush167@users.noreply.github.com> +Date: Sun Oct 3 22:22:40 2021 +0530 + + Add files via upload + +commit 97239c756450d01997598ecf4c57ecc6c277a886 +Merge: 45f3a2c 50d194f +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 22:21:14 2021 +0530 + + Merge pull request #19 from Ayush167/main + + Ayush.java + +commit 50d194f441966f39c5d28ced8d81e299f024c66c +Author: Ayush167 <57669505+Ayush167@users.noreply.github.com> +Date: Sun Oct 3 22:19:21 2021 +0530 + + Add files via upload + +commit 45f3a2c9b76d9f549f60fb61b5b2c87b530e6adc +Merge: ef4e1f8 dd1594e +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 22:17:03 2021 +0530 + + Merge pull request #16 from MarkoKosmajac/java-aes-encryption-decryption + + AES java algorithm + +commit ef4e1f865ffc4faa8df935ebcbdd001d66ca2800 +Merge: ced9b07 63fc7ba +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 22:16:02 2021 +0530 + + Merge pull request #18 from Ayush167/main + + Sample.java + +commit ced9b07706b0e4fcba7cd2bf7a6f3ce45b25b9ab +Merge: c9a2bd7 0a14a84 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 22:15:42 2021 +0530 + + Merge pull request #17 from AbhinandanAdhikari/java-zigzag + + Java Program to Print Numbers in ZigZag Pattern + +commit 63fc7ba3f6ec0d6904048b7235a7f17fa7119720 +Author: Ayush167 <57669505+Ayush167@users.noreply.github.com> +Date: Sun Oct 3 22:11:30 2021 +0530 + + Add files via upload + +commit 0a14a84902119426cb2a1b26332c2dc232ac504a +Author: Abhinandan Adhikari +Date: Sun Oct 3 19:05:18 2021 +0530 + + Java Program for ZigZag Pattern + +commit dd1594e191614653f323be80f647de9b0bff7c09 +Author: Thefaxepower +Date: Sun Oct 3 15:08:05 2021 +0200 + + AES java algoritgm + +commit c9a2bd7d1d88754ed706cecacc12b8eb01648e82 +Merge: 33f7207 48cf263 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 18:33:47 2021 +0530 + + Merge pull request #14 from Venkatesh-24/main + + Added Shell Sort and Quick Sort + +commit 33f7207e45709fd5254c78d143ff78ef77fca4c6 +Merge: 9b77675 4a6b4e8 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 18:33:20 2021 +0530 + + Merge pull request #15 from AbhinandanAdhikari/java-bubblesort + + Added Java program for BubbleSort + +commit 4a6b4e83aca37b9d1f0aad9e010b0b7ab623a775 +Author: Abhinandan Adhikari +Date: Sun Oct 3 13:06:34 2021 +0530 + + Added Java program for BubbleSort + +commit 48cf263b12413b438e2ebb8a1254e79faed28bde +Author: Venkatesh-24 +Date: Sun Oct 3 12:40:26 2021 +0530 + + Added Shell Sort and Quick Sort + +commit 9b77675c41019004b742d33732d271aad7c9df99 +Merge: f23fe73 438e9dc +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 12:28:05 2021 +0530 + + Merge pull request #13 from jotdeep/main + + Added Longest Common Subsequence + +commit 438e9dc4185cf3abf022fa6387123ce9dd9c8ab4 +Author: jotdeep <59995823+jotdeep@users.noreply.github.com> +Date: Sun Oct 3 11:47:55 2021 +0530 + + Added Longest Common Subsequence + +commit f23fe73c68120192666c909ce7916b7489c4fdeb +Merge: 7b5c2f0 608bfe1 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 11:28:43 2021 +0530 + + Merge pull request #12 from abhishekprasad2384/main + + Create Kth Smallest Element in a BST + +commit 608bfe18584c6c6125c1fd5a5e316c725dc69db6 +Author: abhishekprasad2384 <49679013+abhishekprasad2384@users.noreply.github.com> +Date: Sun Oct 3 09:10:55 2021 +0530 + + Create Kth Smallest Element in a BST + +commit 7b5c2f05f2cec4072561d57e3248385553763a18 +Merge: cc5ebe8 8a51e2d +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 08:30:12 2021 +0530 + + Merge pull request #11 from dvir019/patch-1 + + Create ArraySum.java + +commit 8a51e2d8848909baf0f453a323f08d9f072880bd +Author: dvir019 <30556126+dvir019@users.noreply.github.com> +Date: Sun Oct 3 00:04:21 2021 +0300 + + Create ArraySum.java + +commit cc5ebe8f96dcc8ddd0481d7159a4b9ff8b2ac29f +Merge: 2fc7f78 c3c6004 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 01:56:40 2021 +0530 + + Merge pull request #10 from Mystery-2-Dev/main + + Create assendingArray.java + +commit c3c6004d7172cbf0cb9b115d21cefc1661a9b751 +Author: Mysterious-Developer +Date: Sun Oct 3 01:45:53 2021 +0530 + + Create assendingArray.java + +commit 2fc7f780c732537a0247b5ebe4dadd08198dddd7 +Merge: ab981f3 d093aeb +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 01:32:46 2021 +0530 + + Merge pull request #9 from shivu2806/main + + Create egyptianFraction.java + +commit d093aeb1b99fbd269dd587f18113565455bc6790 +Author: shivu2806 <91802335+shivu2806@users.noreply.github.com> +Date: Sun Oct 3 01:31:44 2021 +0530 + + Create egyptianFraction.java + +commit ab981f397d1542c7400e22c1d180752fbed6d012 +Merge: 9f7f6d7 c29394e +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 01:28:43 2021 +0530 + + Merge pull request #7 from Raghav-Gupta22/patch-1 + + Create WordCounter.java + +commit 9f7f6d790147aa651ca9c5dd1c3b4e621b5d260f +Merge: c6e8ded 9c6370c +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 01:28:24 2021 +0530 + + Merge pull request #8 from shivu2806/main + + Create wordBreak.java + +commit 9c6370cad4cfc4d276fcb88b90a2b5538d978fa6 +Author: shivu2806 <91802335+shivu2806@users.noreply.github.com> +Date: Sun Oct 3 01:27:12 2021 +0530 + + Create wordBreak.java + +commit c29394e969ec5379e0cb4d6b6856525fb1a369c6 +Author: Raghav Gupta +Date: Sun Oct 3 01:22:51 2021 +0530 + + Create WordCounter.java + + Java program to count no of words from given input string. + +commit c6e8ded8684faa456e58b28886ae297c9563cd37 +Merge: 13407e4 18fad71 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 01:19:28 2021 +0530 + + Merge pull request #6 from shivu2806/main + + topologicalSorting.java + +commit 18fad717d18f7dc5245ab7275993f57c379d5237 +Author: shivu2806 <91802335+shivu2806@users.noreply.github.com> +Date: Sun Oct 3 01:18:37 2021 +0530 + + initial + +commit 13407e4a32f14254335732517056689966cba595 +Merge: ecb8dab ea0c5ef +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 01:16:21 2021 +0530 + + Merge pull request #5 from shivu2806/main + + matrixChain.java + +commit ea0c5efeb1331bb96aaadee066fc21635d34e787 +Author: shivu2806 <91802335+shivu2806@users.noreply.github.com> +Date: Sun Oct 3 01:15:57 2021 +0530 + + initial + +commit c1cd1d0d54e0fb87eb8b95c4e47008fa4bf3caad +Author: shivu2806 <91802335+shivu2806@users.noreply.github.com> +Date: Sun Oct 3 01:11:37 2021 +0530 + + createdminCost + +commit 61e4d11a232500888f5083d0e27874720beed9a3 +Author: shivu2806 <91802335+shivu2806@users.noreply.github.com> +Date: Sun Oct 3 01:10:06 2021 +0530 + + initial + +commit ecb8dab7cf908fca7cdd51e529796fb0db8bf544 +Merge: 77cbedf d67ac89 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 01:09:07 2021 +0530 + + Merge pull request #2 from Mystery-2-Dev/patch-2 + + Create unicode.java + +commit 77cbedfce9ce0551598cb0ec325463479143b061 +Merge: bfaaf6e 55f5394 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 01:08:55 2021 +0530 + + Merge pull request #3 from Mystery-2-Dev/patch-3 + + Create diagonalSum.java + +commit bfaaf6e825b5e90869ef094db4346382f32ad061 +Merge: 4ca4062 855ff4c +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 01:08:39 2021 +0530 + + Merge pull request #4 from Mystery-2-Dev/patch-4 + + Create ElementbetweenArray.java + +commit 855ff4c2741aa2aed6397f2d3ac90c3eda16afaa +Author: Mysterious-Developer +Date: Sun Oct 3 01:06:33 2021 +0530 + + Create ElementbetweenArray.java + +commit 55f53948528ec3af742f2f1a029333fbe0fa3d0f +Author: Mysterious-Developer +Date: Sun Oct 3 01:04:12 2021 +0530 + + Create diagonalSum.java + +commit d67ac89ef8dadecc551869527c8c3ff1dc36691f +Author: Mysterious-Developer +Date: Sun Oct 3 01:01:39 2021 +0530 + + Create unicode.java + +commit 4ca4062476c02e93e6f3d09cefdc3f95c21f9997 +Merge: cb261a8 27842f6 +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 00:59:51 2021 +0530 + + Merge pull request #1 from Mystery-2-Dev/patch-1 + + Create stringUsage.java + +commit 27842f6aa1c5d66affde842d145e287ac09c1a7d +Author: Mysterious-Developer +Date: Sun Oct 3 00:59:13 2021 +0530 + + Create stringUsage.java + +commit cb261a847ae6006a89ddcba8fe2d88523cadb4da +Author: Aakash kumar sahoo <56172886+jvm-coder@users.noreply.github.com> +Date: Sun Oct 3 00:55:18 2021 +0530 + + Initial commit diff --git a/dijkstrasAlgorithm.java b/dijkstrasAlgorithm.java new file mode 100644 index 0000000..4894fd2 --- /dev/null +++ b/dijkstrasAlgorithm.java @@ -0,0 +1,176 @@ +// Java Program to Implement Dijkstra's Algorithm +// Using Priority Queue + + +import java.util.*; + + +public class GFG { + + + private int dist[]; + private Set settled; + private PriorityQueue pq; + + private int V; + List > adj; + + // Constructor of this class + public GFG(int V) + { + + // This keyword refers to current object itself + this.V = V; + dist = new int[V]; + settled = new HashSet(); + pq = new PriorityQueue(V, new Node()); + } + + // Method 1 + // Dijkstra's Algorithm + public void dijkstra(List > adj, int src) + { + this.adj = adj; + + for (int i = 0; i < V; i++) + dist[i] = Integer.MAX_VALUE; + + // Add source node to the priority queue + pq.add(new Node(src, 0)); + + // Distance to the source is 0 + dist[src] = 0; + + while (settled.size() != V) { + + // Terminating ondition check when + // the priority queue is empty, return + if (pq.isEmpty()) + return; + + // Removing the minimum distance node + // from the priority queue + int u = pq.remove().node; + + // Adding the node whose distance is + // finalized + if (settled.contains(u)) + + // Continue keyword skips exwcution for + // following check + continue; + + // We don't have to call e_Neighbors(u) + // if u is already present in the settled set. + settled.add(u); + + e_Neighbours(u); + } + } + + // Method 2 + // To process all the neighbours + // of the passed node + private void e_Neighbours(int u) + { + + int edgeDistance = -1; + int newDistance = -1; + + // All the neighbors of v + for (int i = 0; i < adj.get(u).size(); i++) { + Node v = adj.get(u).get(i); + + // If current node hasn't already been processed + if (!settled.contains(v.node)) { + edgeDistance = v.cost; + newDistance = dist[u] + edgeDistance; + + // If new distance is cheaper in cost + if (newDistance < dist[v.node]) + dist[v.node] = newDistance; + + // Add the current node to the queue + pq.add(new Node(v.node, dist[v.node])); + } + } + } + + // Main driver method + public static void main(String arg[]) + { + + int V = 5; + int source = 0; + + // Adjacency list representation of the + // connected edges by declaring List class object + // Declaring object of type List + List > adj + = new ArrayList >(); + + // Initialize list for every node + for (int i = 0; i < V; i++) { + List item = new ArrayList(); + adj.add(item); + } + + // Inputs for the GFG(dpq) graph + adj.get(0).add(new Node(1, 9)); + adj.get(0).add(new Node(2, 6)); + adj.get(0).add(new Node(3, 5)); + adj.get(0).add(new Node(4, 3)); + + adj.get(2).add(new Node(1, 2)); + adj.get(2).add(new Node(3, 4)); + + // Calculating the single source shortest path + GFG dpq = new GFG(V); + dpq.dijkstra(adj, source); + + // Printing the shortest path to all the nodes + // from the source node + System.out.println("The shorted path from node :"); + + for (int i = 0; i < dpq.dist.length; i++) + System.out.println(source + " to " + i + " is " + + dpq.dist[i]); + } +} + +// Class 2 +// Helper class implementing Comparator interface +// Representing a node in the graph +class Node implements Comparator { + + // Member variables of this class + public int node; + public int cost; + + // Constructors of this class + + // Constructor 1 + public Node() {} + + // Constructor 2 + public Node(int node, int cost) + { + + // This keyword refers to current instance itself + this.node = node; + this.cost = cost; + } + + // Method 1 + @Override public int compare(Node node1, Node node2) + { + + if (node1.cost < node2.cost) + return -1; + + if (node1.cost > node2.cost) + return 1; + + return 0; + } +} diff --git a/range.cpp b/range.cpp new file mode 100644 index 0000000..4eb36d0 --- /dev/null +++ b/range.cpp @@ -0,0 +1,32 @@ +// C++ program to find total count of an element +// in a range +#include +using namespace std; + +// Returns count of element in arr[left-1..right-1] +int findFrequency(int arr[], int n, int left, + int right, int element) +{ + int count = 0; + for (int i=left-1; i<=right; ++i) + if (arr[i] == element) + ++count; + return count; +} + +// Driver Code +int main() +{ + int arr[] = {2, 8, 6, 9, 8, 6, 8, 2, 11}; + int n = sizeof(arr) / sizeof(arr[0]); + + // Print frequency of 2 from position 1 to 6 + cout << "Frequency of 2 from 1 to 6 = " + << findFrequency(arr, n, 1, 6, 2) << endl; + + // Print frequency of 8 from position 4 to 9 + cout << "Frequency of 8 from 4 to 9 = " + << findFrequency(arr, n, 4, 9, 8); + + return 0; +} diff --git a/rotate_array.java b/rotate_array.java new file mode 100644 index 0000000..8b612a7 --- /dev/null +++ b/rotate_array.java @@ -0,0 +1,47 @@ +package functions; +import java.io.*; + +public class rotate_array { + public static void display(int[] a){ + StringBuilder sb = new StringBuilder(); + + for(int val: a){ + sb.append(val + " "); + } + System.out.println(sb); + } + public static void reverse(int[] a, int m, int k){ + for(int i=m;i > adj; - - // Constructor - Graph(int v) - { - V = v; - adj = new ArrayList >(v); - for (int i = 0; i < v; ++i) - adj.add(new ArrayList()); +class Graph{ + int v; + LinkedList adj[]; + @SuppressWarnings("unchecked") + Graph(int v){ + this.v=v; + adj=new LinkedList[v]; + for(int i=0;i(); + } +} +class TopologicalSorting{ + public static void addEdge(Graph g,int u,int v){ + g.adj[u].add(v); } - - // Function to add an edge into the graph - void addEdge(int v, int w) { adj.get(v).add(w); } - - // A recursive function used by topologicalSort - void topologicalSortUtil(int v, boolean visited[], - Stack stack) + public static void toposortutil(Graph g,int node,boolean visit[],Stack st) { - // Mark the current node as visited. - visited[v] = true; - Integer i; - - // Recur for all the vertices adjacent - // to thisvertex - Iterator it = adj.get(v).iterator(); - while (it.hasNext()) { - i = it.next(); - if (!visited[i]) - topologicalSortUtil(i, visited, stack); + visit[node]=true; + int i; + Iteratorit=g.adj[node].iterator(); + while(it.hasNext()) + { + i=it.next(); + System.out.println(i); + if(!visit[i]) + toposortutil(g,i,visit,st); } - - // Push current vertex to stack - // which stores result - stack.push(new Integer(v)); + System.out.println("node"+node); + st.push(node); } - - // The function to do Topological Sort. - // It uses recursive topologicalSortUtil() - void topologicalSort() - { - Stack stack = new Stack(); - - // Mark all the vertices as not visited - boolean visited[] = new boolean[V]; - for (int i = 0; i < V; i++) - visited[i] = false; - - // Call the recursive helper - // function to store - // Topological Sort starting - // from all vertices one by one - for (int i = 0; i < V; i++) - if (visited[i] == false) - topologicalSortUtil(i, visited, stack); - - // Print contents of stack - while (stack.empty() == false) - System.out.print(stack.pop() + " "); + public static void toposort(Graph g){ + Stack st=new Stack(); + boolean visit[]=new boolean[g.v]; + for(int i=0;i +using namespace std; + +// Function to print all triplets in +// given sorted array that forms AP +void printAllAPTriplets(int arr[], int n) +{ + unordered_set s; + for (int i = 0; i < n - 1; i++) + { + for (int j = i + 1; j < n; j++) + { + // Use hash to find if there is + // a previous element with difference + // equal to arr[j] - arr[i] + int diff = arr[j] - arr[i]; + if (s.find(arr[i] - diff) != s.end()) + cout << arr[i] - diff << " " << arr[i] + << " " << arr[j] << endl; + } + s.insert(arr[i]); + } +} + +// Driver code +int main() +{ + int arr[] = { 2, 6, 9, 12, 17, + 22, 31, 32, 35, 42 }; + int n = sizeof(arr) / sizeof(arr[0]); + printAllAPTriplets(arr, n); + return 0; +}