Skip to content

Instantly share code, notes, and snippets.

View danicat's full-sized avatar

Daniela Petruzalek danicat

View GitHub Profile
@danicat
danicat / list.h
Last active December 25, 2015 22:19
Singly linked list implementation with templates.
#ifndef DANI_SIMPLE_LIST_H_
#define DANI_SIMPLE_LIST_H_
/*
Singly Linked List generic implementation using templates.
Author: Daniela Petruzalek (https://gist.github.com/danicat)
Date : October, 20th 2013
*/
@danicat
danicat / tree.h
Last active December 25, 2015 23:59
Simple binary search tree implementation using templates. Depends on my list.h gist (https://gist.github.com/danicat/7049073).
#ifndef DANI_SIMPLE_TREE_H_
#define DANI_SIMPLE_TREE_H_
/*
Simple Binary Search Tree generic implementation using templates.
Depends: list.h (see github for newest version).
Author: Daniela Petruzalek (https://gist.github.com/danicat)
Date : October, 20th 2013
@danicat
danicat / hash.h
Created October 20, 2013 15:51
Simple Hash Table generic implementation using templates. The underlying collection for storing hash collisions is a binary search tree.
#ifndef DANI_SIMPLE_HASHTABLE_H_
#define DANI_SIMPLE_HASHTABLE_H_
/*
Simple Hash Table generic implementation using templates.
The underlying collection for storing hash collisions is a binary search tree.
Depends: tree.h (see github for newest version).
Author: Daniela Petruzalek (https://gist.github.com/danicat)
@danicat
danicat / avltree.h
Last active March 15, 2022 23:38
AVL Tree implementation in C++ using templates. Still missing some functionality though, like deletion. Work in progress.
#ifndef DANI_AVL_TREE_H_
#define DANI_AVL_TREE_H_
/*
Balanced Binary Search Tree using AVL algorithm.
Depends: list.h (see github for newest version).
Author: Daniela Petruzalek (https://gist.github.com/danicat)
Date : October, 20th 2013
@danicat
danicat / SRM_144_Div1_300.cpp
Created January 4, 2014 21:14
TopCoder SRM 144 Div 1 300 points
#include <vector>
#include <string>
#include <iostream>
using std::vector;
using std::string;
const string kNone = "NONE";
class BinaryCode {
@danicat
danicat / SRM_144_Div2_200.cpp
Created January 5, 2014 18:53
TopCoder SRM 144 Division 2 200 points problem.
#include <vector>
#include <string>
#include <sstream>
using std::vector;
using std::string;
using std::stringstream;
class Time {
public:
@danicat
danicat / SRM_144_Div2_1100.cpp
Created January 5, 2014 22:41
TopCoder SRM 144 Division 2 1100 pts problem. It took me a while to figure this out, but once you notice that the technician must traverse each junction twice except for the largest path the solution comes quite straightforward.
#include <vector>
using std::vector;
class PowerOutage {
public:
int estimateTimeOut(vector<int> fromJunction, vector<int> toJunction, vector<int> ductLength) {
int max_minutes = 0;
for(auto p : ductLength) {
@danicat
danicat / SRM_145_Div2_250.cpp
Created January 6, 2014 12:52
TopCoder SRM 145 Division 2 250 pts
#include <vector>
#include <string>
using std::vector;
using std::string;
class ImageDithering {
public:
int count(string dithered, vector<string> screen) {
int c = 0;
@danicat
danicat / SRM_145_Div2_500.cpp
Created January 6, 2014 12:53
TopCoder SRM 145 Division 2 500 pts
#include <string>
#include <vector>
#include <sstream>
using std::string;
using std::vector;
using std::stringstream;
class ExerciseMachine {
public:
@danicat
danicat / SRM_502_Div2_250.cpp
Created January 6, 2014 15:01
TopCoder SRM 502 Division 2 250 pts.
#include <vector>
#include <algorithm>
using namespace std;
class TheProgrammingContestDivTwo {
public:
vector<int> find(int T, vector<int> requiredTime) {
vector<int> res;