Skip to content

Commit f4b9794

Browse files
author
manjunatha
committed
Code arranged
1 parent 45db463 commit f4b9794

19 files changed

+30
-40
lines changed

Diff for: algorithms/graph/backtracking/CountNoOfPaths.java

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
/**
44
* Count number of paths from source(0,0) to (r-1, c-1)
5-
* @see https://www.geeksforgeeks.org/count-number-ways-reach-destination-maze/
65
* @author Manjunath Asundi
76
*/
87
public class CountNoOfPaths {

Diff for: algorithms/graph/shortest/Floydwarshall.java

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
/**
44
* @author Manjunath Asundi
5-
* @see https://www.geeksforgeeks.org/floyd-warshall-algorithm-dp-16/#
65
* Find all shortest paths from each vertex
76
*/
87
public class Floydwarshall {

Diff for: datastructure/hashmap/ArrayContainsContiguousElements.java

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ static boolean isArrayContainsContiguousIntegers(int arr[]) {
2929

3030
/**
3131
* ArrayContainsContiguousElements
32-
* link https://www.geeksforgeeks.org/check-array-contains-contiguous-integers-duplicates-allowed/
3332
*/
3433
public class ArrayContainsContiguousElements {
3534

Diff for: datastructure/hashmap/DifferenceOfMaxMinFrequency.java

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ static int differenceBetweenMaxMinFrequency(int arr[]) {
3333

3434
/**
3535
* DifferenceOfMaxMinFrequency link
36-
* https://www.geeksforgeeks.org/difference-between-highest-and-least-frequencies-in-an-array/
3736
*/
3837
public class DifferenceOfMaxMinFrequency {
3938
public static void main(String[] args) {

Diff for: datastructure/hashmap/DivisibleByOneAnother.java

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ static Set<Integer> findSpecialNumbers(List<Integer> list) {
3030

3131
/**
3232
* DivisibleByOneAnother
33-
* link https://www.geeksforgeeks.org/divisibility-check/
3433
*/
3534
public class DivisibleByOneAnother {
3635

Diff for: datastructure/hashmap/EmpMgrCount.java

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ static int populateResult(String emp, Map<String, List<String>> mgrEmp, Map<Stri
5454

5555
/**
5656
* EmpMgrCount
57-
* link https://www.geeksforgeeks.org/find-number-of-employees-under-every-manager/
5857
*/
5958
public class EmpMgrCount {
6059

Diff for: datastructure/hashmap/FindABCD.java

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ static void findFourElements(List<Integer> list) {
2929

3030
/**
3131
* find A+B=C+D
32-
* Link https://www.geeksforgeeks.org/find-four-elements-a-b-c-and-d-in-an-array-such-that-ab-cd/
3332
*/
3433
public class FindABCD {
3534
public static void main(String[] args) {

Diff for: datastructure/hashmap/LargestSubArrayWithSumZero.java

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ static int printLargestSubArrayWithSumZero(int arr[]) {
2626

2727
/**
2828
* LargestSubArrayWithSumZero Link
29-
* https://www.geeksforgeeks.org/find-the-largest-subarray-with-0-sum/
3029
*/
3130
public class LargestSubArrayWithSumZero {
3231
public static void main(String[] args) {

Diff for: datastructure/hashmap/MaxLengthOfConsSequence.java

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ static int findMaxLengthOfConsecutiveSequence(int arr[]) {
2626

2727
/**
2828
* MaxLengthOfConsSequence
29-
* link https://www.geeksforgeeks.org/longest-increasing-consecutive-subsequence/
3029
*/
3130
public class MaxLengthOfConsSequence {
3231
public static void main(String[] args) {

Diff for: datastructure/hashmap/PrintMaxLengthConSeq.java

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ static void findMaxLengthOfConsecutiveSequence(int arr[]) {
3030

3131
/**
3232
* PrintMaxLengthConSeq
33-
* link https://www.geeksforgeeks.org/printing-longest-increasing-consecutive-subsequence/
3433
*/
3534
public class PrintMaxLengthConSeq {
3635

Diff for: datastructure/hashmap/SumOfTwo.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
import java.util.Set;
55

66
/**
7-
* @author Manjunath Asundi
7+
* @author Manjunath Asundi
88
*/
99
public class SumOfTwo {
1010

1111
static void sumOfTwoElements(int arr[], int sum) {
1212
Set<Integer> set = new HashSet<Integer>();
1313
for (int i = 0; i < arr.length; i++) {
14-
if(set.contains(sum-arr[i])) System.out.println(arr[i] + " "+ (sum-arr[i]));
15-
else set.add(arr[i]);
14+
if (set.contains(sum - arr[i]))
15+
System.out.println(arr[i] + " " + (sum - arr[i]));
16+
else
17+
set.add(arr[i]);
1618
}
1719
}
20+
1821
public static void main(String[] args) {
19-
int arr[] = {3,2,4,5,7,11,9,8,3,13};
22+
int arr[] = { 3, 2, 4, 5, 7, 11, 9, 8, 3, 13 };
2023
int sum = 12;
2124
sumOfTwoElements(arr, sum);
2225
}

Diff for: datastructure/hashmap/hard/TripletsSumEqualToK.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import java.util.Arrays;
44

55
/**
6-
* @author Manjunath Asundi Print all triplets those sum equal to K
6+
* Print all triplets those sum equal to K
7+
*
8+
* @author Manjunath Asundi
79
*/
810
public class TripletsSumEqualToK {
911
public static void findTripletsSumEqualToK(int arr[], int k) {

Diff for: datastructure/heap/ConnectRopesWithMaxCost.java

-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
/**
77
* ConnectRopesWithMinCost
8-
*
98
* @apiNote Connect N ropes with maximum cost
10-
* @see https://www.geeksforgeeks.org/connect-n-ropes-minimum-cost/
119
* @author Manjunath Asundi
1210
*/
1311
public class ConnectRopesWithMaxCost {

Diff for: datastructure/heap/ConnectRopesWithMinCost.java

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* ConnectRopesWithMinCost
88
*
99
* @apiNote Connect N ropes with minimum cost
10-
* @see https://www.geeksforgeeks.org/connect-n-ropes-minimum-cost/
1110
* @author Manjunath Asundi
1211
*/
1312
public class ConnectRopesWithMinCost {

Diff for: datastructure/heap/MaxHeap.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package datastructure.heap;
22

33
/**
4-
* @author Manjunath Asundi
4+
* @author Manjunath Asundi MinHeap
55
*/
66
class InnerMaxHeap {
77

@@ -35,9 +35,6 @@ static void heapify(int arr[]) {
3535
}
3636
}
3737

38-
/**
39-
* MinHeap
40-
*/
4138
public class MaxHeap {
4239
public static void main(String[] args) {
4340
int arr[] = { 4, 10, 3, 5, 1 };

Diff for: datastructure/heap/MinHeap.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package datastructure.heap;
22

33
/**
4+
* MaxHeap
45
* @author Manjunath Asundi
56
*/
67
class InnerMinHeap {
@@ -23,8 +24,8 @@ static void buildMinHeap(int arr[], int root, int n) {
2324

2425
static void heapify(int arr[]) {
2526
int n = arr.length;
26-
for (int i = (n -1) / 2; i >= 0; i--)
27-
buildMinHeap(arr, i, n-1);
27+
for (int i = (n - 1) / 2; i >= 0; i--)
28+
buildMinHeap(arr, i, n - 1);
2829

2930
for (int i = n - 1; i >= 0; i--) {
3031
buildMinHeap(arr, 0, i);
@@ -42,9 +43,6 @@ static void printArray(int arr[]) {
4243
}
4344
}
4445

45-
/**
46-
* MaxHeap
47-
*/
4846
public class MinHeap {
4947
public static void main(String[] args) {
5048
int arr[] = { 4, 10, 3, 5, 1 };

Diff for: datastructure/linkedlist/FindMiddleNode.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
11
package datastructure.linkedlist;
22

33
/**
4-
* @author Manjunath Asundi
4+
* Find middle node from linkedlist
5+
*
6+
* @author Manjunath Asundi
57
*/
68
class Node {
79
int data;
810
Node next;
11+
912
public Node(int data) {
1013
this.data = data;
1114
this.next = null;
12-
}
15+
}
1316
}
1417

15-
/**
16-
* FindMiddleNode
17-
*/
1818
public class FindMiddleNode {
1919

2020
static void findMiddleElement(Node list) {
21-
Node fastPointer = list, slowPointer = list;
22-
while(fastPointer.next!=null && fastPointer!=null) {
21+
Node fastPointer = list, slowPointer = list;
22+
while (fastPointer.next != null && fastPointer != null) {
2323
slowPointer = slowPointer.next;
2424
fastPointer = fastPointer.next.next;
25-
}
26-
System.out.println("Middle Element:"+ slowPointer.data);
25+
}
26+
System.out.println("Middle Element:" + slowPointer.data);
2727
}
2828

2929
static void printList(Node list) {
30-
while(list!=null) {
30+
while (list != null) {
3131
System.out.print(list.data + " ");
3232
list = list.next;
3333
}
3434
System.out.println();
3535
}
36+
3637
public static void main(String[] args) {
3738
Node list = new Node(1);
3839
list.next = new Node(2);

Diff for: datastructure/tree/bst/KthSmallest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import datastructure.tree.Node;
44

55
/**
6-
* @author Manjunath Asundi
6+
* @author Manjunath Asundi
77
*/
88
class InnerKthSmallest {
99
static int count = 0;
@@ -23,7 +23,6 @@ static void findKthSmallest(Node<Integer> tree, int k) {
2323

2424
/**
2525
* KthSmallest link
26-
* https://www.geeksforgeeks.org/find-k-th-smallest-element-in-bst-order-statistics-in-bst/
2726
*/
2827
public class KthSmallest {
2928
public static void main(String[] args) {

Diff for: problemsolving/DivideAbyB.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import java.util.Map;
55

66
/**
7-
* Divide A by B without using float data type and repeating floating point string should need to be enclosed by parenthesis
7+
* Divide A by B without using float data type and repeating floating point
8+
* string should need to be enclosed by parenthesis
9+
*
810
* @author Manjunath Asundi
911
*/
1012
public class DivideAbyB {
@@ -40,5 +42,6 @@ public static void main(String[] args) {
4042
System.out.println(divide(1, 97));
4143
System.out.println(divide(4, 11));
4244
System.out.println(divide(18, 13));
45+
System.out.println(divide(10, 7));
4346
}
4447
}

0 commit comments

Comments
 (0)