Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar
💭
If I have seen further it is only by standing on the shoulders of giants. NEWTON

Adrian Statescu thinkphp

💭
If I have seen further it is only by standing on the shoulders of giants. NEWTON
View GitHub Profile
#include <bits/stdc++.h>
#define FIN "cautbin.in"
#define FOUT "cautbin.out"
using namespace std;
//returns the largest index such that arr[i] == key
// or -1 whether the key is not in the array
int binary_search0(int *arr, int lo, int hi, int key) {
if(lo > hi) {
@thinkphp
thinkphp / lrucache.cpp
Created June 7, 2026 08:56
LRU Cache - doubly Linked List | Hash Map
#include <iostream>
#include <unordered_map>
/*
capacity = 5
Head 11 8 5 1 4 Tail
tail->prev inseamna nodul cu key 7
head->next = inseamna nodul cu key 8
@thinkphp
thinkphp / BFS-ADJmatrix.cpp
Created June 7, 2026 07:50
Parcurgere in latime - graful este reprezentat prin matricea de adiacenta
//BFS > graful este reprezentat prin matricea de adiacenta
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
class GrafMatrice {
@thinkphp
thinkphp / BFS-LinkedListAdj.cpp
Created June 7, 2026 07:48
Parcurgere in latime , matricea este stocata in liste de adiacenta
#include <iostream>
#include <queue>
using namespace std;
struct Node {
int vecin;
Node*urmator;
Node(int vecin): vecin(vecin), urmator(nullptr) {}
@thinkphp
thinkphp / 2sum-leetcode.cpp
Created June 7, 2026 06:47
solutia optima pentru 2Sum
class Solution {
public:
vector<int> twoSum(vector<int> &nums, int target) {
map<int,int> mp;
int n = num.size();
-- Daca Team ori Player este inregistrat in Diqualifications table, trebuie o formula automata / trigger sa activeze in entitatea corecta (Team ori Player, dupa caz), in atributul Player_Registration_Status / Team_Registration_Status optiunea ‘Disqualified’
DELIMITER $$
CREATE TRIGGER trg_player_disqualification
AFTER INSERT ON Disqualifications
FOR EACH ROW
BEGIN
IF NEW.Player_ID IS NOT NULL THEN
UPDATE Player
SET Player_Registration_Status = 'Disqualified'
@thinkphp
thinkphp / gist:aa285bf16394ac95a640b848eca94bca
Created May 31, 2026 20:00
Only 'F' can be assigned Athletics_100m_Hurdles
DELIMITER $$
CREATE TRIGGER trg_athlete_hurdles_gender_check
BEFORE INSERT ON Athlete_Profile
FOR EACH ROW
BEGIN
DECLARE v_gender ENUM('M', 'F');
-- Retrieve the player's gender from the Player supertype
SELECT Gender
#include <iostream>
#include <vector>
#define FIN "graf.in"
#define FIN2 "graf-liste.in"
using namespace std;
class Graf {
private:
@thinkphp
thinkphp / tsp.cpp
Last active May 30, 2026 07:49
TSP Traveling Salesman Problem O(n!) complexitate
/*
Input:
Numar de noduri si matricea costurilor
5
0 9 0 8 0
7 0 1 0 3
5 0 0 0 4
0 0 6 0 0
0 1 0 7 0
*/
@thinkphp
thinkphp / introducere-advancedDB.txt
Created May 25, 2026 17:45
introducere-advancedDB
1. Introduction
This report presents the physical database design for a multi-sport tournament management system. The system is modelled after real-world events such as the Commonwealth Games and the European Championships (European Athletics, 2025). The design covers data management across multiple sports, scheduling, results recording, standings calculation, and performance reporting.
The physical model has been developed in accordance with the requirements of the assignment brief and is presented as a crow's foot Enhanced Entity-Relationship Diagram (EERD) created using Lucidchart. This report accompanies that diagram and provides the design assumptions, rationale, and justification for key architectural decisions including the chosen inheritance strategy, denormalisation approach, and non-key indexing.
2. Design Assumptions and Rationale
A number of assumptions were made during the design process to resolve ambiguities in the scenario and to reflect realistic tournament management requirements. These ar