Diff
checker
Text
Text
Images
Documents
Excel
Folders
Legal
Enterprise
Desktop
Pricing
Sign in
Download Diffchecker Desktop
Compare text
Find the difference between two text files
Tools
History
Real-time editor
Hide unchanged lines
Disable line wrap
Layout
Split
Unified
Diff precision
Smart
Word
Char
Syntax highlighting
Choose syntax
Ignore
Transform text
Go to first change
Edit input
Diffchecker Desktop
The most secure way to run Diffchecker. Get the Diffchecker Desktop app: your diffs never leave your computer!
Get Desktop
Untitled Diff
Created
4 years ago
Diff never expires
Clear
Export
Share
Explain
7 removals
Lines
Total
Removed
Characters
Total
Removed
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
27 lines
Copy
7 additions
Lines
Total
Added
Characters
Total
Added
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
27 lines
Copy
Copy
Copied
Copy
Copied
//
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:
Copy
Copied
Copy
Copied
// 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) { }
Copy
Copied
Copy
Copied
// 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;
}
}
}
}
Copy
Copied
Copy
Copied
// 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;
}
}
};
};
Saved diffs
Original text
Open file
// 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; } };
Changed text
Open file
// 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; } };
Find difference