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 / dynamic_programmig.txt
Created March 21, 2026 09:54
Programare Dinamica cu un exemplu clasic: problema triunghiului
Programare Dinamica
-------------------
Este o tehnica care conduce , de cele mai multe ori, la un timp de calcul polinomial.Mai mult,
furnizeaza intotdeauna solutia OPTIMA. Din nefericire, programarea dinamica nu se poate aplica tuturor problemelor , ci numai celor care indeplinesc anumite conditii.
Se considera o problema in care rezultatul se obtine care urmare a unui sir de DECIZII
D1, D2, D3, ..., Dn.
@thinkphp
thinkphp / sortare prin interclasare.cpp
Created March 21, 2026 09:23
Metoda sortarii prin interclasare sortare prin interclasare.cpp
#include <iostream>
#include <vector>
using namespace std;
//4 5 6
//i
//1 2 3
// j
@thinkphp
thinkphp / interclasare_vectori.cpp
Created March 21, 2026 09:11
interclasare vectori interclasare_vectori.cpp
#include <iostream>
#include <vector>
using namespace std;
vector<int> interclasare(const vector<int> A, const vector<int> B) {
vector<int> R;
int i = 0, j = 0;
@thinkphp
thinkphp / bubblesort-selectionbymin.cpp
Created March 21, 2026 07:53
Metode de sortare . Complexitate polinomiala. bubblesort-selectionbymin.cpp
#include <iostream>
#include <vector>
using namespace std;
//5 4 3 2 1
//prima iteratie: 4 3 2 1 5
//a doua: 1 2 3 4 5
//(a[0],a[1]) (a[1],a[2]),...(a[3],a[4])
@thinkphp
thinkphp / teorie
Created March 20, 2026 18:16
permutari Backtracking teorie
- Permutari n = 3
n! = 3! = 6
1 2 3
.....
3 2 1
- generare de submultimi
@thinkphp
thinkphp / Backtracking.java
Created March 20, 2026 18:15
generare permutari cu Backtracking
public class Main {
static int[] perm;
static boolean[] used;
//1 , 3
static void solve(int level, int n) {
if(level == n + 1) {//4 == 3 + 1= 4 TRUE
@thinkphp
thinkphp / palindrome.java
Created March 20, 2026 17:42
palindrome.java LeetCode
//algoritm clasic
public class Main {
static class Solution {
//x = 121
public boolean isPalindrome( int x ) {
int n = x;
@thinkphp
thinkphp / uglyNumber-Leetcode.java
Created March 20, 2026 17:22
uglyNumber-Leetcode.java
// n = 14
public class Main {
static class Solution {
public boolean isUgly(int n) {
//n = 123 :3= 41
int[] factors = { 2, 3, 5 };
@thinkphp
thinkphp / BubbleSort.java
Created March 20, 2026 16:52
BubbleSort.java Complexita
public class BubbleSort {
//Complexitate O(N^2)
public static void BubbleSort(int[] arr) {
int n = arr.length;
for(int i = 0; i < n; i++) {
boolean swapped = false;
@thinkphp
thinkphp / Euclid2.java
Created March 20, 2026 16:31
Euclid2.java fara fisier de intrare si iesire
import java.io.*;
import java.util.Scanner;
public class Euclid2 {
static int Euclid( int a, int b ) {
while( b != 0) {
int r = a % b;