Diff
checker
Texte
Texte
Images
Documents
Excel
Dossiers
Legal
Enterprise
Application de bureau
Prix
Se connecter
Télécharger Diffchecker Desktop
Comparer le texte
Trouver la différence entre deux fichiers texte
Outils
Historique
Éditeur live
Cacher identiques
Sans retour à la ligne
Vue
Divisé
Unifié
Niveau de précision
Intelligent
Mot
Caractère
Coloration syntaxique
Choisir la syntaxe
Ignorer
Transformer le texte
Aller au premier écart
Modifier l'entrée
Diffchecker Desktop
La façon la plus sécurisée d'utiliser Diffchecker. Obtenez l'application Diffchecker Desktop : vos diffs ne quittent jamais votre ordinateur !
Obtenir Desktop
Untitled Diff
Créé
il y a 4 ans
Le diff n'expire jamais
Effacer
Exporter
Partager
Expliquer
7 suppressions
Lignes
Total
Supprimé
Caractères
Total
Supprimé
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
27 lignes
Copier tout
7 ajouts
Lignes
Total
Ajouté
Caractères
Total
Ajouté
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
27 lignes
Copier tout
Copier
Copié
Copier
Copié
//
Fenwick tree
class
//
BIT
class
class
FenwickTree
{
class
BIT
{
// Array to store the
Fenwick tree
// Array to store the
BIT
vector<int> tree;
vector<int> tree;
public:
public:
Copier
Copié
Copier
Copié
// Constructor to create an empty
Fenwick tree
with the given size
// Constructor to create an empty
BIT
with the given size
FenwickTree
(int size) : tree(size + 1) { }
BIT
(int size) : tree(size + 1) { }
Copier
Copié
Copier
Copié
// Add the given value at the given index in the
Fenwick tree
// Add the given value at the given index in the
BIT
void add(int index, int value) {
void add(int index, int value) {
while (index < tree.size()) {
while (index < tree.size()) {
tree[index] += value;
tree[index] += value;
index += index & -index;
index += index & -index;
}
}
}
}
Copier
Copié
Copier
Copié
// Query the
Fenwick tree
for the prefix sum at the given index
// Query the
BIT
for the prefix sum at the given index
int query(int index) {
int query(int index) {
int sum = 0;
int sum = 0;
while (index > 0) {
while (index > 0) {
sum += tree[index];
sum += tree[index];
index -= index & -index;
index -= index & -index;
}
}
return sum;
return sum;
}
}
};
};
Différences enregistrées
Texte d'origine
Ouvrir un fichier
// Fenwick tree class class FenwickTree { // Array to store the Fenwick tree vector<int> tree; public: // Constructor to create an empty Fenwick tree with the given size FenwickTree(int size) : tree(size + 1) { } // Add the given value at the given index in the Fenwick tree void add(int index, int value) { while (index < tree.size()) { tree[index] += value; index += index & -index; } } // Query the Fenwick tree for the prefix sum at the given index int query(int index) { int sum = 0; while (index > 0) { sum += tree[index]; index -= index & -index; } return sum; } };
Texte modifié
Ouvrir un fichier
// BIT class class BIT { // Array to store the BIT vector<int> tree; public: // Constructor to create an empty BIT with the given size BIT(int size) : tree(size + 1) { } // Add the given value at the given index in the BIT void add(int index, int value) { while (index < tree.size()) { tree[index] += value; index += index & -index; } } // Query the BIT for the prefix sum at the given index int query(int index) { int sum = 0; while (index > 0) { sum += tree[index]; index -= index & -index; } return sum; } };
Trouver la différence