This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]"), ""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int indiceGauche = 0, indiceDroit = sAlpha.length - 1; indiceGauche < indiceDroit; indiceGauche++, indiceDroit--) { | |
// Logique magique | |
} |
OlderNewer