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 / 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;
@thinkphp
thinkphp / triunghiul-pascal.cpp
Created March 28, 2026 08:44
triunghiul-pascal.cpp
#include <iostream>
#include <vector>
using namespace std;
//programare dinamica
class Solution {
public:
vector<vector<int>> generate(int numRows) {
@thinkphp
thinkphp / sortare prin insertie.cpp
Created March 28, 2026 08:13
sortare prin insertie.cpp
#include <iostream>
#include <vector>//template
//bubblesort, selection by minimum, insertion sort
//2 3 9 4 -1 23 4 54
//
using namespace std;
@thinkphp
thinkphp / isHappy.cpp
Created March 28, 2026 08:02
isHappy
#include <iostream>
using namespace std;
class Solution {
//n = 18
public:
@thinkphp
thinkphp / collatz.cpp
Created March 25, 2026 18:59
collatz algoritm
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
unsigned n;//input n natural
cin>>n;
@thinkphp
thinkphp / fibverif.c
Created March 25, 2026 18:46
Pbinfo fibverif.c
#include <stdio.h>
void fb() {
int n;
scanf("%d", &n);
int arr[ n ];
for(int i = 0; i < n; ++i) scanf("%d", &arr[i]);