Skip to content

Instantly share code, notes, and snippets.

View youssef3wi's full-sized avatar

Aouichaoui Youssef youssef3wi

  • Kairouan, Tunisie
View GitHub Profile
@youssef3wi
youssef3wi / Factorize.java
Last active February 21, 2026 19:04
Write a program to "factorize" the extremities of two ASCII strings `str1` and `str2`.
/**
* Write a program to "factorize" the extremities of two ASCII strings {@code str1} and {@code str2}.
* <p>
* Your must return a single string, initially made from the concatenation of two given strings.
* The longest substrings that is common between the end of the first string and the beginning
* of the second one must be factorized (written only once).
* <p>
* You must decide the concatenation order {@code str1 + str2} or {@code str2 + str1} so that
* you get the best factorization.
* <p>
@youssef3wi
youssef3wi / PgNotify.java
Last active September 18, 2025 18:49
An example that demystifies pg_notify using PostgreSQL's native connection.
import org.postgresql.PGNotification;
import org.postgresql.ds.PGSimpleDataSource;
import org.postgresql.jdbc.PgConnection;
import java.sql.SQLException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import static java.lang.Thread.ofVirtual;
@youssef3wi
youssef3wi / MergePersonData.java
Created August 28, 2025 19:48
You collected data about persons from multiple sources. You would like to consolidate them.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
/**
* You collected data about persons from multiple sources. You would like to consolidate them.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* In the echanted land of Evenaria,
* an elf named Codelia was searching for the mystical Even Stones, which maintained balance and harmony.
* One day, she discovered an ancient scroll with a list of numbers representing their locations.
* However, the scroll was damaged and the numbers looked scrambled.
* <p>
@youssef3wi
youssef3wi / CountPeaks.java
Created August 28, 2025 18:46
CountPeaks
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Your company builds radioactivity sensors.
* You are responsible for their verification process.
* You know that when a sensor is failing, the value it outputs have big variations on short time periods.
* <p>
* The input parameter {@code values}, a list of decimal numbers,
@youssef3wi
youssef3wi / BackToSchool.java
Created October 31, 2024 13:01
Back to school
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import static java.util.Arrays.asList;
@youssef3wi
youssef3wi / Translate.java
Created October 12, 2024 13:24
Le javanais, aussi appelé langue de feu, est un procédé de codage argotique qui fut utilisé à la fin du 19ème siècle par certains malfaiteurs pour crypter leur conversations.
/**
* <h2>Objectif</h2>
* <p>
* Le javanais, aussi appelé langue de feu, est un procédé de codage argotique qui fut utilisé
* à la fin du 19ème siècle par certains malfaiteurs pour crypter leur conversations. Écrivez un programme
* retournant la traduction en javanais d'une phrase.
* <p>
* <h3>Fonctionnement</h3>
* <p>
* <ul>
@youssef3wi
youssef3wi / EvenPosition.java
Created October 12, 2024 11:13
Renvoyer true si value est contenu dans la liste numbers à un index pair (les index sont comptés à partir de 0).
import java.util.List;
import java.util.stream.IntStream;
import static java.util.Arrays.asList;
/**
* Écrivez le corps de la méthode {@link #isOnEvenPosition(List, int)}.
* <p>
* La méthode doit renvoyer le booléen {@code true} si {@code value} est contenu dans la liste
* {@code numbers} à un index pair (les index sont comptés à partir de 0). {@code value} peut
@youssef3wi
youssef3wi / SmallestInterval.java
Created October 12, 2024 10:58
Implémentez la méthode smallestInterval(numbers) qui retourne le plus petit intervalle positif entre deux éléments du tableau numbers.
import java.security.SecureRandom;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import static java.lang.System.nanoTime;
import static java.util.Arrays.asList;
@youssef3wi
youssef3wi / StudentChecker.java
Last active October 12, 2024 10:58
You are tasked with validating student records from an array RecArray, where each element is in the format <name>:<roll_no>:<marks>.
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* <b>Unique Array</b>
* <p>