Skip to content

Instantly share code, notes, and snippets.

View JustDravee's full-sized avatar

Dravee JustDravee

View GitHub Profile
import 'package:interview_algorithms_dart/longest-substring-without-repeating-characters.dart';
import 'package:test/test.dart';
void main() {
test("Chaîne vide", () {
expect(longestSubstringWithoutRepeatingCharacters(""), "");
});
test("Chaîne entière", () {
expect(
import 'package:interview_algorithms_dart/palindrome-le-plus-long.dart';
import 'package:test/test.dart';
void main() {
test("Chaîne vide", () {
expect(palindromeLePlusLong(""), "");
});
test("Chaîne entière", () {
expect(palindromeLePlusLong("lol"), "lol");
// Définition de la classe Palindrome
class Palindrome {
int indiceDebut; // Indice de début du Palindrome sur le texteInitial
int taille; // Taille du Palindrome
String texteInitial; // Texte sur lequel nous cherchons un Palindrome
// Initialise un Palindrome
Palindrome(String nouvelleChaine) {
indiceDebut = 0;
taille = 1; // Si 1 seul caractère, il est son propre Palindrome
class Palindrome {
int indiceDebut;
int taille;
String texteInitial;
Palindrome(String nouvelleChaine) {
indiceDebut = 0;
taille = 1; // Si 1 seul caractère, il est son propre Palindrome
texteInitial = nouvelleChaine;
}
import 'package:interview_algorithms_dart/bloc-code-valide.dart';
import 'package:test/test.dart';
void main() {
test("Chaîne vide invalide", () {
expect(blocCodeValide(""), false);
});
test("Caractère(s) invalide(s) de bloc de code", () {
expect(blocCodeValide("a"), false);
import 'dart:collection';
bool blocCodeValide(String s) {
// Null et empty check. Un bloc de taille < 2 est invalide
if (["", null].contains(s) || s.length < 2) {
return false;
}
;
// Init
Queue stack = Queue();
import 'package:interview_algorithms_dart/anagrammes.dart';
import 'package:test/test.dart';
void main() {
test("Chaîne vide", () {
expect(anagrammes("", ""), false);
});
test("Chaîne avec 1 espace seulement", () {
expect(anagrammes(" ", " "), false);
bool anagrammes(String s1, String s2) {
// Check null
if (["", null].contains(s1) || ["", null].contains(s2)) {
return false;
}
// On enlève les caractères non alpha
String s1Alpha = s1.replaceAll(RegExp(r"[^a-zA-Z]"), "");
String s2Alpha = s2.replaceAll(RegExp(r"[^a-zA-Z]"), "");
import 'package:interview_algorithms_dart/est-palindrome.dart';
import 'package:test/test.dart';
void main() {
test("Chaîne vide", () {
expect(estPalindrome(""), false);
});
test("Caractère unique", () {
expect(estPalindrome("a"), true);
for (int indiceGauche = 0, indiceDroit = sAlpha.length - 1; indiceGauche < indiceDroit; indiceGauche++, indiceDroit--) {
// Logique magique
}