-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'krahets:master' into docs/support-golang-chapter1
- Loading branch information
Showing
128 changed files
with
1,834 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: array.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: linked_list.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: list.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: my_list.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
6 changes: 6 additions & 0 deletions
6
codes/cpp/chapter_computational_complexity/leetcode_two_sum.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: leetcode_two_sum.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
6 changes: 6 additions & 0 deletions
6
codes/cpp/chapter_computational_complexity/space_complexity_types.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: space_complexity_types.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
6 changes: 6 additions & 0 deletions
6
codes/cpp/chapter_computational_complexity/time_complexity_types.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: time_complexity_types.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
6 changes: 6 additions & 0 deletions
6
codes/cpp/chapter_computational_complexity/worst_best_time_complexity.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: worst_best_time_complexity.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: binary_search.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: hashing_search.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: linear_search.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: bubble_sort.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: insertion_sort.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: merge_sort.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: quick_sort.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: array_queue.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: array_stack.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: deque.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: linkedlist_queue.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: linkedlist_stack.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: queue.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: stack.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: binary_search_tree.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: binary_tree.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: binary_tree_bfs.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* File: binary_tree_dfs.cpp | ||
* Created Time: 2022-11-25 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* File: PrintUtil.hpp | ||
* Created Time: 2021-12-19 | ||
* Author: Krahets (krahets@163.com) | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <iostream> | ||
using namespace std; | ||
|
||
/** | ||
* @brief Definition for a singly-linked list node | ||
* | ||
*/ | ||
struct ListNode { | ||
int val; | ||
ListNode *next; | ||
ListNode(int x) : val(x), next(nullptr) {} | ||
}; | ||
|
||
/** | ||
* @brief Generate a linked list with a vector | ||
* | ||
* @param list | ||
* @return ListNode* | ||
*/ | ||
ListNode* vectorToLinkedList(vector<int> list) { | ||
ListNode *dum = new ListNode(0); | ||
ListNode *head = dum; | ||
for (int val : list) { | ||
head->next = new ListNode(val); | ||
head = head->next; | ||
} | ||
return dum->next; | ||
} | ||
|
||
/** | ||
* @brief Get a list node with specific value from a linked list | ||
* | ||
* @param head | ||
* @param val | ||
* @return ListNode* | ||
*/ | ||
ListNode* getListNode(ListNode *head, int val) { | ||
while (head != nullptr && head->val != val) { | ||
head = head->next; | ||
} | ||
return head; | ||
} |
Oops, something went wrong.