Skip to content

Commit

Permalink
⚡ perf: delete dynamic array
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchuo committed Mar 19, 2019
1 parent 0965714 commit a240dc4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
7 changes: 1 addition & 6 deletions AdvancedLevel_C++/1089. Insert or Merge (25).cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
#include <algorithm>
using namespace std;
int main() {
int n;
int n, a[100], b[100], i, j;
cin >> n;
int *a = new int [n];
int *b = new int [n];
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++)
cin >> b[i];
int i, j;
for (i = 0; i < n - 1 && b[i] <= b[i + 1]; i++);
for (j = i + 1; a[j] == b[j] && j < n; j++);
if (j == n) {
Expand All @@ -35,7 +32,5 @@ int main() {
if (j != 0) printf(" ");
printf("%d", a[j]);
}
delete [] a;
delete [] b;
return 0;
}
7 changes: 1 addition & 6 deletions BasicLevel_C++/1035. 插入与归并(25).cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
#include <algorithm>
using namespace std;
int main() {
int n;
int n, a[100], b[100], i, j;
cin >> n;
int *a = new int [n];
int *b = new int [n];
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++)
cin >> b[i];
int i, j;
for (i = 0; i < n - 1 && b[i] <= b[i + 1]; i++);
for (j = i + 1; a[j] == b[j] && j < n; j++);
if (j == n) {
Expand All @@ -35,7 +32,5 @@ int main() {
if (j != 0) printf(" ");
printf("%d", a[j]);
}
delete [] a;
delete [] b;
return 0;
}

0 comments on commit a240dc4

Please sign in to comment.