Skip to content

Commit cde14ef

Browse files
committed
Merge branch 'feature/type' into develop
2 parents 5b54467 + 41c6fa3 commit cde14ef

22 files changed

+45
-45
lines changed

cpp-algorithm/src/array/dutch_national_flag.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
auto DutchFlag::DutchFlagPartition1(const int pivot_index, std::vector<Color>& arr) -> std::vector<Color>
44
{
5-
const auto pivot = arr[pivot_index];
5+
const Color pivot = arr[pivot_index];
66

77
for (int i = 0; i < static_cast<Color>(arr.size()); ++i)
88
{
@@ -32,7 +32,7 @@ auto DutchFlag::DutchFlagPartition1(const int pivot_index, std::vector<Color>& a
3232

3333
auto DutchFlag::DutchFlagPartition2(const int pivot_index, std::vector<Color>& arr) -> std::vector<Color>
3434
{
35-
const auto pivot = arr[pivot_index];
35+
const Color pivot = arr[pivot_index];
3636

3737
int smaller = 0;
3838
for (int i = 0; i < static_cast<Color>(arr.size()); ++i)
@@ -57,7 +57,7 @@ auto DutchFlag::DutchFlagPartition2(const int pivot_index, std::vector<Color>& a
5757

5858
auto DutchFlag::DutchFlagPartition3(const int pivot_index, std::vector<Color>& arr) -> std::vector<Color>
5959
{
60-
const auto pivot = arr[pivot_index];
60+
const Color pivot = arr[pivot_index];
6161

6262
int smaller = 0;
6363
int equal = 0;

cpp-algorithm/src/array/stock_trading.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ auto StockTrading::BuyAndSellStockOnce(const std::vector<int>& prices) -> double
2727

2828
for (double price : prices)
2929
{
30-
auto max_profit_sell_today = price - min_price_so_far;
30+
double max_profit_sell_today = price - min_price_so_far;
3131
max_profit = std::max(max_profit, max_profit_sell_today);
3232
min_price_so_far = std::min(min_price_so_far, price);
3333
}

cpp-algorithm/src/graph/dijkstra.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void Dijkstra::Graph::DijkstraAlgorithm(Vertex& source)
2929
void Dijkstra::Graph::ReorderQueue(std::priority_queue<Vertex*, std::vector<Vertex*>, MinComparator>& min_queue)
3030
{
3131
auto queue = std::priority_queue<Vertex*, std::vector<Vertex*>, MinComparator>{};
32-
const auto min_queue_size = static_cast<int>(min_queue.size());
32+
const int min_queue_size = static_cast<int>(min_queue.size());
3333

3434
for (int i = 0; i < min_queue_size; ++i)
3535
{

cpp-algorithm/src/greedy/activity_selection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ auto ActivitySelection::RecursiveActivitySelector(const std::vector<int>& start,
1515

1616
if (sub_index < size)
1717
{
18-
auto activities = RecursiveActivitySelector(start, finish, sub_index, size);
18+
std::vector<int> activities = RecursiveActivitySelector(start, finish, sub_index, size);
1919
activities.push_back(sub_index);
2020

2121
return activities;

cpp-algorithm/src/hashtable/anonymous_letter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ auto SplitIntoWords(const std::string& str) -> std::unordered_map<std::string, i
5656
auto AnonymousLetter::IsWordConstructibleFromMagazine(const std::string& letter, const std::string& magazine) -> bool
5757
{
5858
// count the number of times each word appears in the letter
59-
auto word_frequency_for_letter = SplitIntoWords(letter);
59+
std::unordered_map<std::string, int> word_frequency_for_letter = SplitIntoWords(letter);
6060

6161
// check if the words in magazine can cover words in letter
6262
for (const auto& [fst, snd] : SplitIntoWords(magazine))

cpp-algorithm/src/hashtable/collatz_conjecture.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ auto CollatzConjecture::GenerateCollatzSequence(const long long number,
2121
// if number is even, then divide it by 2
2222
if (number % 2 == 0)
2323
{
24-
auto sub_sequence = GenerateCollatzSequence(number / 2, hash_table);
24+
std::vector<long long> sub_sequence = GenerateCollatzSequence(number / 2, hash_table);
2525
sequence.insert(sequence.end(), sub_sequence.begin(), sub_sequence.end());
2626
}
2727
// if number is odd, then multiply it by 3 and add 1
2828
else
2929
{
30-
auto sub_sequence = GenerateCollatzSequence(number * 3 + 1, hash_table);
30+
std::vector<long long> sub_sequence = GenerateCollatzSequence(number * 3 + 1, hash_table);
3131
sequence.insert(sequence.end(), sub_sequence.begin(), sub_sequence.end());
3232
}
3333

@@ -42,7 +42,7 @@ auto CollatzConjecture::FindNumbersSatisfyingCollatzConjecture(const long long n
4242
for (long long i = 1LL; i < number; ++i)
4343
{
4444
// if the Collatz sequence ends with 1, then satisfies the Collatz conjecture
45-
if (auto sequence = GenerateCollatzSequence(i, hash_table); sequence.back() == 1)
45+
if (std::vector<long long> sequence = GenerateCollatzSequence(i, hash_table); sequence.back() == 1)
4646
{
4747
satisfied_numbers.push_back(i);
4848
}

cpp-algorithm/src/hashtable/find_anagram.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ auto FindAnagram::FindAnagramMappings(const std::vector<std::string>& dictionary
99
std::unordered_map<std::string, std::vector<std::string>> dictionary_map;
1010
for (const std::string& word : dictionary)
1111
{
12-
auto sorted_word = word;
12+
std::string sorted_word = word;
1313
std::ranges::sort(sorted_word);
1414
dictionary_map[sorted_word].emplace_back(word);
1515
}

cpp-algorithm/src/hashtable/smallest_subarray.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ auto SmallestSubarray::FindSmallestSubarrayCoveringSubset(const std::vector<std:
1414
++keywords_to_cover[keyword];
1515
}
1616

17-
auto result = std::make_tuple(-1, -1);
18-
auto remaining_to_cover = keywords.size();
17+
std::tuple<int, int> result = std::make_tuple(-1, -1);
18+
size_t remaining_to_cover = keywords.size();
1919

2020
for (int left_index = 0, right_index = 0; right_index < static_cast<int>(paragraph.size()); ++right_index)
2121
{
@@ -72,11 +72,11 @@ auto SmallestSubarray::FindSmallestSubarraySequentiallyCoveringSubset(const std:
7272
keywords_to_index[keywords[i]] = i;
7373
}
7474

75-
auto last_occurrence = std::vector(keywords.size(), -1);
76-
auto shortest_subarray_length = std::vector(keywords.size(), std::numeric_limits<int>::max());
75+
std::vector<int> last_occurrence = std::vector(keywords.size(), -1);
76+
std::vector<int> shortest_subarray_length = std::vector(keywords.size(), std::numeric_limits<int>::max());
7777

7878
int shortest_distance = std::numeric_limits<int>::max();
79-
auto result = std::make_tuple(-1, -1);
79+
std::tuple<int, int> result = std::make_tuple(-1, -1);
8080

8181
for (int i = 0; i < static_cast<int>(paragraph.size()); ++i)
8282
{

cpp-algorithm/src/heap/closest_star.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ auto ClosestStar::FindClosestStar(std::vector<Star>& stars, const int k) -> std:
88

99
while (!stars.empty())
1010
{
11-
auto star = stars.back();
11+
Star star = stars.back();
1212
stars.pop_back();
1313

1414
if (static_cast<int>(max_heap.size()) < k)

cpp-algorithm/src/linkedlist/delete_list_node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void DeleteListNode::DeleteNodeFromList(std::shared_ptr<LinkedList::Node<int>>&
99
auto DeleteListNode::DeleteNodeKthLast(std::shared_ptr<LinkedList::Node<int>>& list, int k)
1010
-> std::shared_ptr<LinkedList::Node<int>>
1111
{
12-
auto dummy_head = std::make_shared<LinkedList::Node<int>>(LinkedList::Node<int>{0, list});
12+
const auto dummy_head = std::make_shared<LinkedList::Node<int>>(LinkedList::Node<int>{0, list});
1313

1414
auto precede = dummy_head->next;
1515
while (k--)

0 commit comments

Comments
 (0)