Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aad6bc3

Browse filesBrowse files
committed
updates
1 parent 779d9e0 commit aad6bc3
Copy full SHA for aad6bc3

28 files changed

+48
-63
lines changed

‎.idea/workspace.xml

Copy file name to clipboardExpand all lines: .idea/workspace.xml
+11-7Lines changed: 11 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

‎src/com/company/Lecture11/QuickSort.java

Copy file name to clipboardExpand all lines: src/com/company/Lecture11/QuickSort.java
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.company.Lecture11;
22

33
import com.company.Lecture5.ArrayIntro;
4-
54
import java.util.Arrays;
65

76
public class QuickSort {
@@ -15,12 +14,9 @@ public static void quicksort(int[] nums,int start, int end){
1514
if(start >= end){
1615
return;
1716
}
18-
1917
int p = pivot(nums,start,end);
20-
2118
quicksort(nums,start,p-1);
2219
quicksort(nums,p+1,end);
23-
2420
}
2521

2622
public static int pivot(int[] nums,int start,int end){

‎src/com/company/Lecture11/SumDivideArray.java

Copy file name to clipboardExpand all lines: src/com/company/Lecture11/SumDivideArray.java
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public static void main(String[] args) {
1313
// sumTarget(nums,0,10,0,new ArrayList<>());
1414
}
1515

16-
public static void divide(int[] nums,int index, int sum1, int sum2, ArrayList<Integer> list1,ArrayList<Integer> list2){
16+
public static void divide(int[] nums, int index, int sum1, int sum2,
17+
ArrayList<Integer> list1,ArrayList<Integer> list2){
1718
if( index == nums.length){
1819
if(sum1 == sum2){
1920
System.out.println(list1 + " : " + list2);
@@ -33,7 +34,8 @@ public static void divide(int[] nums,int index, int sum1, int sum2, ArrayList<In
3334

3435
}
3536

36-
public static void sumTarget(int[] nums, int index, int target, int sum, ArrayList<Integer> list){
37+
public static void sumTarget(int[] nums, int index, int target,
38+
int sum, ArrayList<Integer> list){
3739
if(index == nums.length){
3840
if(sum == target && list.size() == 3){
3941
System.out.println(list);

‎src/com/company/Lecture12/CountPallindrome.java

Copy file name to clipboardExpand all lines: src/com/company/Lecture12/CountPallindrome.java
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ public class CountPallindrome {
44
public static void main(String[] args) {
55
String line = "aabbaa";
66
System.out.println(count(line));
7-
87
}
98

109
public static int count(String line){
1110
int count = 0;
12-
1311
for(int i = 0; i < line.length();i++){
14-
1512
//Check for odd length
1613
int left = i;
1714
int right = i;
@@ -22,7 +19,6 @@ public static int count(String line){
2219
break;
2320
}
2421
}
25-
2622
//Check for even length
2723
left = i;
2824
right = i+1;
@@ -34,7 +30,6 @@ public static int count(String line){
3430
}
3531
}
3632
}
37-
3833
return count;
3934
}
4035
}

‎src/com/company/Lecture22/AdjMapWeightGraph.java

Copy file name to clipboardExpand all lines: src/com/company/Lecture22/AdjMapWeightGraph.java
+26-26Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,32 @@ public Edge(Vertex start, Vertex end, Integer weight) {
2828
}
2929
}
3030

31+
private Map<Vertex, Vertex> generateParents(){
32+
Map<Vertex,Vertex> parents = new HashMap<Vertex, Vertex>();
33+
for(Vertex vertex : vertices.values()){
34+
parents.put(vertex, null);
35+
}
36+
return parents;
37+
}
38+
39+
private Vertex find(Vertex vertex, Map<Vertex, Vertex> parents){
40+
while (parents.get(vertex) != null){
41+
vertex = parents.get(vertex);
42+
}
43+
return vertex;
44+
}
45+
46+
private boolean Union(Vertex first,Vertex second, Map<Vertex, Vertex> parents){
47+
first = find(first, parents);
48+
second = find(second, parents);
49+
50+
if(first != second) {
51+
parents.put(first, second);
52+
return true;
53+
}
54+
return false;
55+
}
56+
3157
public Integer kruskal(){
3258
ArrayList<Edge> list = new ArrayList<Edge>();
3359
for(Vertex start : vertices.values()){
@@ -114,32 +140,6 @@ public void removeEdge(E first, E second){
114140
}
115141
}
116142

117-
private Map<Vertex, Vertex> generateParents(){
118-
Map<Vertex,Vertex> parents = new HashMap<Vertex, Vertex>();
119-
for(Vertex vertex : vertices.values()){
120-
parents.put(vertex, null);
121-
}
122-
return parents;
123-
}
124-
125-
private Vertex find(Vertex vertex, Map<Vertex, Vertex> parents){
126-
while (parents.get(vertex) != null){
127-
vertex = parents.get(vertex);
128-
}
129-
return vertex;
130-
}
131-
132-
private boolean Union(Vertex first,Vertex second, Map<Vertex, Vertex> parents){
133-
first = find(first, parents);
134-
second = find(second, parents);
135-
136-
if(first != second) {
137-
parents.put(first, second);
138-
return true;
139-
}
140-
return false;
141-
}
142-
143143
public void DFT(E value){
144144
Vertex v = vertices.get(value);
145145

‎src/com/company/Lecture23/Sudoku.java

Copy file name to clipboardExpand all lines: src/com/company/Lecture23/Sudoku.java
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ public static void sudoku(int[][] board, int row, int col){
2626
display(board);
2727
return;
2828
}
29-
3029
if(col == board.length){
3130
sudoku(board,row+1, 0);
3231
return;
3332
}
34-
3533
if(board[row][col] == 0){
3634
for (int i = 1; i <= 9; i++) {
3735
if(isSafe(board, row, col, i)){
@@ -60,24 +58,20 @@ public static boolean isSafe(int[][] board, int row, int col, int n) {
6058
return false;
6159
}
6260
}
63-
6461
for (int i = 0; i < board.length; i++) {
6562
if(board[i][col] == n){
6663
return false;
6764
}
6865
}
69-
7066
int r_block = row/3;
7167
int c_block = col/3;
72-
7368
for (int r = r_block*3; r < (r_block+1)*3; r++) {
7469
for (int c = c_block*3; c < (c_block+1)*3; c++) {
7570
if (board[r][c] == n){
7671
return false;
7772
}
7873
}
7974
}
80-
8175
return true;
8276
}
8377
}

‎src/com/company/Lecture24/JobSequence.java

Copy file name to clipboardExpand all lines: src/com/company/Lecture24/JobSequence.java
+5-8Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,11 @@ public static void main(String[] args) {
2929
jobs.add(new Job(job_names[i], deadlines[i], values[i]));
3030
}
3131

32-
jobs.sort(new Comparator<Job>() {
33-
@Override
34-
public int compare(Job o1, Job o2) {
35-
if(o1.deadline != o2.deadline){
36-
return o1.deadline - o2.deadline;
37-
}else {
38-
return o2.value - o1.value;
39-
}
32+
jobs.sort((o1, o2) -> {
33+
if(o1.deadline != o2.deadline){
34+
return o1.deadline - o2.deadline;
35+
}else {
36+
return o2.value - o1.value;
4037
}
4138
});
4239
}

‎src/com/company/Lecture24/LongPallindromeSubseq.java

Copy file name to clipboardExpand all lines: src/com/company/Lecture24/LongPallindromeSubseq.java
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,22 @@
22

33
public class LongPallindromeSubseq {
44
public static void main(String[] args) {
5-
System.out.println(lps("abceaa",0,5));
5+
System.out.println(lps("aaceaa",0,5));
66
}
77

88
public static int lps(String line, int start, int end){
99
if(start > end){
1010
return 0;
1111
}
12-
1312
if(start == end){
1413
return 1;
1514
}
16-
17-
int res = 0;
15+
int res;
1816
if(line.charAt(start) == line.charAt(end)){
1917
res = 2 + lps(line, start+1,end-1);
2018
}else {
2119
res = Math.max(lps(line,start,end-1), lps(line,start+1,end));
2220
}
23-
2421
return res;
2522
}
2623
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.