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
@thinkphp
thinkphp / BFSADjList.java
Created June 11, 2026 19:23
BFS cu Adj Lists
import java.io.*;
import java.util.*;
class GraphAdjLinkedList {
private static class Node {
int vecin;
Node urmator;
@thinkphp
thinkphp / DFS-AdjLists.java
Created June 11, 2026 19:04
DFS cu graful reprezentat prin liste de adiacenta
import java.util.Scanner;
/*
0 1
liste de adiacenta:
cap[]
1: 2, 3 cap[1]
2: 1, 5,4 cap[2]
3: 1, 5 cap[3]
@thinkphp
thinkphp / gist:bba4ca0ba450cf83a3fccb9fb5f1f843
Created June 11, 2026 19:03
DFS cu matricea de adiacenta
import java.util.*;
public class Graf {
private final int[][] mat;
public final boolean[] vizitat;
private final int n;
@thinkphp
thinkphp / BFS.java
Last active June 11, 2026 18:58
Breadth First Search - matricea de adiacenta
import java.io.*;
import java.util.*;
class GraphAdjMatrix {
private int[][] mat;
private boolean[] vizitat;
private int n;
public GraphAdjMatrix(int n) {
@thinkphp
thinkphp / doubly-link-list.java
Created June 11, 2026 18:22
Doubly Linked List
@thinkphp
thinkphp / LRUCache.java
Created June 11, 2026 18:19
LRUCache Data Struture
/*
LRU Cache capacitate 5
MostRecently U Least Recenty Used
HEAD(-1) 9 <-> 10 <-> 1 <-> 5 <-> 2(-1)TAIL
Put(5)
get(1)
https://web.stanford.edu/class/cs97si/06-basic-graph-algorithms.pdf
@thinkphp
thinkphp / royfloyd.cpp
Created June 7, 2026 09:02
Algoritmul Roy Floyd
#include <stdio.h>
#define MAX 105
#define FIN "royfloyd.in"
#define FOUT "royfloyd.out"
//function prototypes
void read();
void RoyFloyd();
void write();
#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