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 / codeforces-false-alarm.cpp
Created April 25, 2026 09:11
False Alarm CodeForces.com codeforces-false-alarm.cpp
void solve() {
int n, x;//dimnesiune si butonul apasat: x secunde
cin>>n>>x;
int l = 1e5, r = -1;
for(int i = 0; i < n; ++i) {
@thinkphp
thinkphp / cycle-detection-Floyd.cpp
Created April 25, 2026 08:47
Find Duplicate Cycle Detection Floyd cycle-detection-Floyd.cpp
//1,3,4,2,2
[1,2,3,4]
4/2 = 2
int findDuplicate(vector<int>_&nums) {
int low = 1;
int high = nums.size() - 1;// 5= 5-1= 4
[1,2,3,4]
@thinkphp
thinkphp / find-duplicate-nlogn-binary-search.cpp
Created April 25, 2026 08:29
find-duplicate-nlogn-binary-search.cpp
int findDuplicate(vector<int>_&nums) {
int low = 1;
int high = nums.size() - 1;// 5= 5-1= 4
[1,2,3,4]
@thinkphp
thinkphp / valid-mountain.cpp
Last active April 25, 2026 07:34
valid mountain leetcode
bool validMountain(vector<int>& arr) {
int n = arr.size();
int start = 0;
int end = n - 1;
//urcare
@thinkphp
thinkphp / boyorgirl.java
Created April 19, 2026 17:49
Codeforces Boy or Girl cu SET
public class Main {
//Maarriaa
public static int CountDistinctChars(String s) {
Set<Character> set = new HashSet<>();//caracterele vor fi distincte
for(char c : s.toCharArray()) {//m, a,
@thinkphp
thinkphp / palindrom.java
Created April 19, 2026 17:22
Leetcode valid palindrome
class Solution {
public boolean isPalindrome(String s) {
StringBuilder tmp = new StringBuilder();
//Time Complexity: O(n)
for(char c: s.toCharArray()) {
@thinkphp
thinkphp / knapsack.java
Created April 19, 2026 16:48
DP Problema rucsacului
import java.io.*;
import java.util.*;
public class Rucsac {
public static void main(String[] args) throws IOException {
BufferedReader fin = new BufferedReader(new FileReader("rucsac.in"));
@thinkphp
thinkphp / teorie-tehnici-de-programare.txt
Created April 19, 2026 15:49
Trecere in revista: Brute-Force, Bkt, Dynamic PRogramming, Divide et impera
Brute-force --->> incerci toate variantele posibile
Backtracking - te intorci daca nu mai poti inainta
Greedy - >alegi mereu cea mai buna decizie locala
- decizii pas cu pas
- nu revii asupra alegerilor
@thinkphp
thinkphp / submultimi.java
Created April 19, 2026 15:21
GEnerare submultimi cu 2 for complexitate O(n2^n)
/*
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= n; ++j) {
}
}
O(n^2)
@thinkphp
thinkphp / rucsac.in
Last active April 18, 2026 09:08
input pentru problema rucsacului
input:
numar de obiecte, capacitate rucsac
urmatoarele linii:
greutate obiecte, profit obiect
5 10
3 2
4 3