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 / backtracking-generare-perm.java
Last active April 2, 2026 16:39
backtracking-generare-perm.java
import java.io.*;
import java.util.Scanner;
/*
1 2 3
1 3 2
.....
3 2 1
n! = 1 * 2 * ... * n
*/
@thinkphp
thinkphp / complexitate Big O Notation.md
Created April 2, 2026 16:14
complexitate Big O Notation.md

/* Introducere in Big O Notation

Cum calculam suma 1 + 2 + 3 + ... + n = ?

Varianta1: Big O(n^2) - complexitate patratica - 2 for Varianta2: Big O(n) - complexitate liniara - un for Varianta3: Big O(1) - complexitate constanta - 1 formula

n^k . unde k = 0,1,2,3,4,5....

@thinkphp
thinkphp / Triangle-Pascal.java
Created March 29, 2026 17:40
Triangle-Pascal.java
/*
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1
1 1
1 1 1
@thinkphp
thinkphp / Cautare Binara - Teorie
Created March 29, 2026 17:20
Cautare Binara - Teorie
Binary Search
------------
Cautarea binara este un algoritm eficient de cautare a unui element intr-un array sortat, care functioneaza prin injumatatirea repetata a spatiului de cautare.
Cum functioneaza?
- se porneste cu intregul array;
@thinkphp
thinkphp / SortingAlgorithms-insertionSort.java
Created March 29, 2026 16:40
SortingAlgorithms-insertionSort-selection by min
//11 12 22 25 64
public class SortingAlgorithms {
//Selection Sort (by minimum)
//la fiecare pas , gasim minimul in subsirul [i, n-1]
//si il punem pe pozitia i prin swap
public static void selectionByMin(int[] arr) {
@thinkphp
thinkphp / RecursiveBinarySearch.java
Created March 29, 2026 16:02
RecursiveBinarySearch.java
public class RecursiveBinarySearch {
public static int RecursiveBinarySearch(int[] arr, int start, int end, int target) {
if( start > end ) {
return -1;//target negasit
}
int mid = start + (end - start) / 2;
@thinkphp
thinkphp / IterativeBinarySearch.java
Created March 29, 2026 15:52
IterativeBinarySearch.java
public class IterativeBinarySearch {
public static int IterativeBinarySearch(int[] arr, int target) {
int start = 0;//limita inferioara
int end = arr.length - 1; //limita superioara
while( start <= end ) {
@thinkphp
thinkphp / infoarena_binary_search.cpp
Created March 28, 2026 11:01
infoarena_binary_search.cpp
#include <iostream>
using namespace std;
int binary_search0(int *arr, int lo, int hi, int key) {
if(lo > hi) {
return -1;
}
@thinkphp
thinkphp / Binary_Search.cpp
Created March 28, 2026 10:26
Binary_Search.cpp Binary Search Algorithm
#include <iostream>
#include <vector>
using namespace std;
int iterativeBinarySearch(const vector<int>&arr, int target) {
int start = 0;
int end = arr.size() - 1;
@thinkphp
thinkphp / triple.cpp
Created March 28, 2026 09:23
triple.cpp
#include <iostream>
#include <vector>
/*
T = 7
9
1 1 1 2 2 2 3 3 3
*/
using namespace std;