Skip to content

Commit

Permalink
Reformatted the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
neerazz committed Sep 11, 2021
1 parent 3223f75 commit 1274783
Show file tree
Hide file tree
Showing 599 changed files with 4,724 additions and 4,748 deletions.
2 changes: 1 addition & 1 deletion Algorithms/All_Topics_top_leetcode_by_frequency.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Leet Code [Explore](https://leetcode.com/explore/learn/)
## Leet Code [Explore](https://leetcode.com/explore/learn/)

| **#** | **Title** | **Acceptance** | **Difficulty** |
| --- | --- | --- | --- |
Expand Down
9 changes: 6 additions & 3 deletions Algorithms/Blind75.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
- Longest Consecutive Sequence - https://leetcode.com/problems/longest-consecutive-sequence/
- Alien Dictionary (Leetcode Premium) - https://leetcode.com/problems/alien-dictionary/
- Graph Valid Tree (Leetcode Premium) - https://leetcode.com/problems/graph-valid-tree/
- Number of Connected Components in an Undirected Graph (Leetcode Premium) - https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/
- Number of Connected Components in an Undirected Graph (Leetcode Premium)
- https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/

---

Expand Down Expand Up @@ -84,7 +85,8 @@

## String

- Longest Substring Without Repeating Characters - https://leetcode.com/problems/longest-substring-without-repeating-characters/
- Longest Substring Without Repeating Characters
- https://leetcode.com/problems/longest-substring-without-repeating-characters/
- Longest Repeating Character Replacement - https://leetcode.com/problems/longest-repeating-character-replacement/
- Minimum Window Substring - https://leetcode.com/problems/minimum-window-substring/
- Valid Anagram - https://leetcode.com/problems/valid-anagram/
Expand All @@ -106,7 +108,8 @@
- Binary Tree Level Order Traversal - https://leetcode.com/problems/binary-tree-level-order-traversal/
- Serialize and Deserialize Binary Tree - https://leetcode.com/problems/serialize-and-deserialize-binary-tree/
- Subtree of Another Tree - https://leetcode.com/problems/subtree-of-another-tree/
- Construct Binary Tree from Preorder and Inorder Traversal - https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/
- Construct Binary Tree from Preorder and Inorder Traversal
- https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/
- Validate Binary Search Tree - https://leetcode.com/problems/validate-binary-search-tree/
- Kth Smallest Element in a BST - https://leetcode.com/problems/kth-smallest-element-in-a-bst/
- Lowest Common Ancestor of BST - https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/
Expand Down
3 changes: 1 addition & 2 deletions Algorithms/EPI_Questions_List.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
### Below are the list of EPI Questions along with the topics.

### Below are the list of EPI Questions along with the topics.

|Topic |Question No|Question |Solution |Page No.|
|--------------------------------|:---------:|----------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----|
Expand Down
3 changes: 0 additions & 3 deletions Algorithms/Neeraj/AlgoExpert/ApartmentHunting.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import java.util.*;
import java.io.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;

/**
* Created on: Mar 17, 2021
Expand Down
3 changes: 0 additions & 3 deletions Algorithms/Neeraj/AlgoExpert/BSTConstruction.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import java.util.*;
import java.io.*;

/**
* Created on: Feb 04, 2021
* Questions:
Expand Down
5 changes: 2 additions & 3 deletions Algorithms/Neeraj/AlgoExpert/BoggleBoard.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import java.util.*;
import java.io.*;

/**
* Created on: Feb 01, 2021
Expand All @@ -8,6 +7,8 @@

public class BoggleBoard {

static int[][] dirs = {{0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}};

public static void main(String[] args) {
System.out.println(boggleBoard(
new char[][]{{'t', 'h', 'i', 's', 'i', 's', 'a'}, {'s', 'i', 'm', 'p', 'l', 'e', 'x'}, {'b', 'x', 'x', 'x', 'x', 'e', 'b'}, {'x', 'o', 'g', 'g', 'l', 'x', 'o'}, {'x', 'x', 'x', 'D', 'T', 'r', 'a'}, {'R', 'E', 'P', 'E', 'A', 'd', 'x'}, {'x', 'x', 'x', 'x', 'x', 'x', 'x'}, {'N', 'O', 'T', 'R', 'E', '-', 'P'}, {'x', 'x', 'D', 'E', 'T', 'A', 'E'}},
Expand Down Expand Up @@ -49,8 +50,6 @@ public static List<String> boggleBoard(char[][] board, String[] words) {
return new ArrayList<>(result);
}

static int[][] dirs = {{0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}};

private static void dfs(char[][] board, int row, int col, int rows, int cols, Trie trie, boolean[][] visited, Set<String> result) {
if (row < 0 || row >= rows || col < 0 || col >= cols || visited[row][col] || trie.cur != board[row][col])
return;
Expand Down
11 changes: 5 additions & 6 deletions Algorithms/Neeraj/AlgoExpert/CalenderMatching.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import java.util.*;
import java.util.stream.Collectors;

/**
* Created on: Feb 24, 2021
Expand Down Expand Up @@ -147,6 +146,11 @@ static class Meeting implements Comparable<Meeting> {
int endHour, endMin;
String start, end;

Meeting(String start, String end) {
setStarting(start);
setEnding(end);
}

public void setStarting(String start) {
this.start = start;
String[] starts = start.split(":");
Expand All @@ -161,11 +165,6 @@ public void setEnding(String end) {
endMin = Integer.parseInt(ends[1]);
}

Meeting(String start, String end) {
setStarting(start);
setEnding(end);
}

// Return the ones that should be started first.
public int compareTo(Meeting other) {
if (this.startHour == other.startHour) {
Expand Down
1 change: 0 additions & 1 deletion Algorithms/Neeraj/AlgoExpert/FindLoop.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Created on: Aug 17, 2020
* Questions: https://www.algoexpert.io/questions/Find%20Loop
Expand Down
21 changes: 10 additions & 11 deletions Algorithms/Neeraj/AlgoExpert/FindNodesDistanceK.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import java.util.*;
import java.io.*;

/**
* Created on: Feb 25, 2021
Expand Down Expand Up @@ -32,16 +31,6 @@ public static void main(String[] args) {

}

static class BinaryTree {
public int value;
public BinaryTree left = null;
public BinaryTree right = null;

public BinaryTree(int value) {
this.value = value;
}
}

public static List<Integer> findNodesDistanceK(BinaryTree tree, int target, int k) {
Map<BinaryTree, BinaryTree> parents = new HashMap<>();
buildParent(tree, null, parents);
Expand Down Expand Up @@ -78,4 +67,14 @@ private static void buildParent(BinaryTree node, BinaryTree parent, Map<BinaryTr
buildParent(node.left, node, map);
buildParent(node.right, node, map);
}

static class BinaryTree {
public int value;
public BinaryTree left = null;
public BinaryTree right = null;

public BinaryTree(int value) {
this.value = value;
}
}
}
3 changes: 0 additions & 3 deletions Algorithms/Neeraj/AlgoExpert/GlobalMatching.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import java.util.*;
import java.io.*;

/**
* Created on: Feb 27, 2021
* Questions:
Expand Down
3 changes: 0 additions & 3 deletions Algorithms/Neeraj/AlgoExpert/InterweavingStrings.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import java.util.*;
import java.io.*;

/**
* Created on: Feb 24, 2021
* Questions: https://www.algoexpert.io/questions/Interweaving%20Strings
Expand Down
3 changes: 0 additions & 3 deletions Algorithms/Neeraj/AlgoExpert/InvertBisection.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import java.util.*;
import java.io.*;

/**
* Created on: Feb 27, 2021
* Questions: https://www.algoexpert.io/assessments/Inverted%20Bisection
Expand Down
1 change: 0 additions & 1 deletion Algorithms/Neeraj/AlgoExpert/RectangleMania.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import java.util.*;
import java.io.*;

/**
* Created on: Feb 04, 2021
Expand Down
3 changes: 0 additions & 3 deletions Algorithms/Neeraj/AlgoExpert/RunLengthEncoding.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import java.util.*;
import java.io.*;

/**
* Created on: Feb 22, 2021
* Questions:
Expand Down
3 changes: 1 addition & 2 deletions Algorithms/Neeraj/AlgoExpert/SquareOfZeros.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import java.util.*;
import java.io.*;
import java.util.List;

/**
* Created on: Feb 07, 2021
Expand Down
3 changes: 0 additions & 3 deletions Algorithms/Neeraj/AlgoExpert/StaircaseTraversal.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import java.util.*;
import java.io.*;

/**
* Created on: Feb 24, 2021
* Questions:
Expand Down
3 changes: 1 addition & 2 deletions Algorithms/Neeraj/AlgoExpert/SubArraySort.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import java.util.*;
import java.io.*;
import java.util.Arrays;

/**
* Created on: Feb 02, 2021
Expand Down
18 changes: 10 additions & 8 deletions Algorithms/Neeraj/AlgoExpert/ValidIPAddresses.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import java.util.*;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Created on: Feb 18, 2021
Expand All @@ -12,12 +14,6 @@ public static void main(String[] args) {

}

public ArrayList<String> validIPAddresses(String str) {
if (str == null || str.length() < 4 || str.length() > 12) return new ArrayList<>();
Map<String, ArrayList<String>> memo = new HashMap<>();
return helper(str, 0, 4, memo);
}

private static ArrayList<String> helper(String str, int start, int k, Map<String, ArrayList<String>> memo) {
String key = "" + start + " " + k;
ArrayList<String> cur = new ArrayList<>();
Expand All @@ -44,4 +40,10 @@ private static ArrayList<String> helper(String str, int start, int k, Map<String
memo.put(key, cur);
return cur;
}

public ArrayList<String> validIPAddresses(String str) {
if (str == null || str.length() < 4 || str.length() > 12) return new ArrayList<>();
Map<String, ArrayList<String>> memo = new HashMap<>();
return helper(str, 0, 4, memo);
}
}
29 changes: 15 additions & 14 deletions Algorithms/Neeraj/Tools/javascript_tools.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link crossorigin="anonymous" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" rel="stylesheet">

<title>Converter For Java</title>
</head>
Expand All @@ -22,42 +22,42 @@
<div class="card">
<div class="card-body">
<h5 class="card-title">Enter input:</h5>
<textarea class="form-control" aria-label="With textarea" id="textInput" placeholder="Input"></textarea>
<textarea aria-label="With textarea" class="form-control" id="textInput" placeholder="Input"></textarea>
</div>
</div>

<div class="card">
<div class="card-body">
<div class="row">
<h5 class="card-title">Class Name:</h5>
<button type="button" class="btn btn-outline-info" onclick="classCopy()">Copy</button>
<button class="btn btn-outline-info" onclick="classCopy()" type="button">Copy</button>
</div>
<textarea class="form-control" aria-label="With textarea" id="output1" placeholder="Input"></textarea>
<textarea aria-label="With textarea" class="form-control" id="output1" placeholder="Input"></textarea>
</div>
</div>

<div class="card">
<div class="card-body">
<div class="row">
<h5 class="card-title">Array Input:</h5>
<button type="button" class="btn btn-outline-info" onclick="arrayInputCopy()">Copy</button>
<button class="btn btn-outline-info" onclick="arrayInputCopy()" type="button">Copy</button>
</div>
<textarea class="form-control" aria-label="With textarea" id="output2" placeholder="Input"></textarea>
<textarea aria-label="With textarea" class="form-control" id="output2" placeholder="Input"></textarea>
</div>
</div>
</div>

<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
<script crossorigin="anonymous"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script crossorigin="anonymous"
integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script crossorigin="anonymous"
integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV"
crossorigin="anonymous"></script>
src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script>

<script>
Expand Down Expand Up @@ -107,6 +107,7 @@ <h5 class="card-title">Array Input:</h5>




</script>

</body>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import java.util.*;
import java.io.*;
import java.util.Arrays;

/**
* Created on: Jan 13, 2021
Expand Down
21 changes: 10 additions & 11 deletions Algorithms/Neeraj/algorithum/binarysearch/ClosestBinarySearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import java.util.TreeSet;

public class ClosestBinarySearch {
static int closestHighest;
static int closestSmallest;
static int closest;

public static void main(String[] args) {
System.out.println("************************ Closest Value ************************");
System.out.println(findClosestValueInBst(new int[]{1, 3, 5, 7, 9, 12, 16, 19}, 10) + " should be [9]");
Expand Down Expand Up @@ -33,7 +37,6 @@ public static void main(String[] args) {
System.out.println("------------------- End Random Testing -----------------------");
}

static int closestHighest;
private static int findHighestClosestValue(int[] arr, int target) {
closestHighest = Integer.MAX_VALUE;
closestHighestHelper(arr, 0, arr.length - 1, target);
Expand Down Expand Up @@ -63,7 +66,6 @@ private static void closestHighestHelper(int[] arr, int start, int end, int targ
}
}

static int closestSmallest;
private static int findLowestClosestValue(int[] arr, int target) {
closestSmallest = Integer.MIN_VALUE;
closestSmallestHelper(arr, 0, arr.length - 1, target);
Expand Down Expand Up @@ -93,9 +95,6 @@ private static void closestSmallestHelper(int[] arr, int start, int end, int tar
}
}


static int closest;

public static int findClosestValueInBst(int[] arr, int target) {
closest = Integer.MAX_VALUE;
if (arr == null || arr.length == 0) return -1;
Expand Down Expand Up @@ -151,8 +150,8 @@ static void testFindHighestClosestValueInBstIndividual(int test) {
for (int i : input) {
set.add(i);
}
int randomIDX = random.nextInt(input.length > 0 ? input.length-1 : 0);
int randomValue = input[randomIDX] +10;
int randomIDX = random.nextInt(input.length > 0 ? input.length - 1 : 0);
int randomValue = input[randomIDX] + 10;
Integer ceiling = set.ceiling(randomValue);
int closestValueInBst = ClosestBinarySearch.findHighestClosestValue(input, randomValue);
if (ceiling != null && closestValueInBst == ceiling) {
Expand All @@ -179,8 +178,8 @@ static void testFindLowestClosestValueIndividual(int test) {
for (int i : input) {
set.add(i);
}
int randomIDX = random.nextInt(input.length > 0 ? input.length-1 : 0);
int randomValue = input[randomIDX] +10;
int randomIDX = random.nextInt(input.length > 0 ? input.length - 1 : 0);
int randomValue = input[randomIDX] + 10;
Integer floor = set.floor(randomValue);
int closestValueInBst = ClosestBinarySearch.findLowestClosestValue(input, randomValue);
if (floor != null && closestValueInBst == floor) {
Expand All @@ -207,8 +206,8 @@ static void testFindClosestValueInBstIndividual(int test) {
for (int i : input) {
set.add(i);
}
int randomIDX = random.nextInt(input.length > 0 ? input.length-1 : 0);
int randomValue = input[randomIDX] +10;
int randomIDX = random.nextInt(input.length > 0 ? input.length - 1 : 0);
int randomValue = input[randomIDX] + 10;
Integer ceiling = set.ceiling(randomValue);
Integer floor = set.floor(randomValue);
int closestValueInBst = ClosestBinarySearch.findClosestValueInBst(input, randomValue);
Expand Down
Loading

0 comments on commit 1274783

Please sign in to comment.