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
from typing import Literal | |
def inorder_traversal(btree): | |
if not btree: | |
return | |
yield from inorder_traversal(btree[0]) | |
yield btree[1] | |
yield from inorder_traversal(btree[2]) |
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
def fizzbuzz(number): | |
""" | |
Return 'Fizz' if `num` is divisible by 3, | |
return 'Buzz' if `num` is divisible by 5, | |
return 'FizzBuzz' if `num` is divisible both by 3 and 5. | |
If `num` isn't divisible neither by 3 nor by 5, return `number`. | |
Example: | |
fizzbuzz(3) # Fizz |
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
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int levenshtein_distance(const string &str_a, const string &str_b) | |
{ | |
if (str_a.empty()) | |
return str_b.length(); |
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
#include <iostream> | |
#include <stack> | |
#include <regex> | |
using namespace std; | |
void print_tags(string text); | |
bool is_start_tag(const string &element); |
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
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <math.h> | |
#include <numeric> | |
using namespace std; | |
typedef struct Point_ | |
{ |
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
#include <iostream> | |
#include <algorithm> | |
#include <unordered_map> | |
using namespace std; | |
bool is_anagram(const string &str_a, const string &str_b) | |
{ | |
unordered_map<char, int> chars_occurrences; |
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
#include <iostream> | |
#include <utility> | |
#include <algorithm> | |
#include <list> | |
#include <iostream> | |
#include <map> | |
#include <stdexcept> | |
#include <vector> | |
#include <functional> | |
#include <queue> |
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
#include <iostream> | |
#include <bitset> | |
#include <vector> | |
#include <cassert> | |
using namespace std; | |
template<size_t bitset_size> | |
int robot_coin_collection(vector<bitset<bitset_size>> &coin_matrix) { |
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
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <functional> | |
using namespace std; | |
template<typename T> | |
vector<T> comparison_counting_sort(vector<T> &array, function<bool(T, T)> key_func) { |
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
#include <iostream> | |
#include "polynomial.h" | |
using namespace std; | |
int main() { | |
{ | |
cout << Polynomial {} << endl; | |
cout << (Polynomial) {-3} << endl; | |
cout << (Polynomial) {-2, 3} << endl; |
OlderNewer