-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
class Solution { | ||
public: | ||
double average(vector<int>& salary) { | ||
sort(salary.begin(), salary.end()); | ||
int len = salary.size(); | ||
double res = 0; | ||
for (int i = 1; i < len - 1; i++) { | ||
res += salary[i]; | ||
} | ||
return res / (len - 2); | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
class Solution { | ||
public: | ||
vector<int> decrypt(vector<int>& code, int k) { | ||
int len = code.size(); | ||
vector<int> ans(len, 0); | ||
if (k == 0) { | ||
return ans; | ||
} | ||
|
||
for (int i = 0; i < len; i++) { | ||
if (k > 0) { | ||
int tmp = k; | ||
while (tmp > 0) { | ||
ans[i] += code[(i + tmp) % len]; | ||
tmp--; | ||
} | ||
} | ||
|
||
if (k < 0) { | ||
int tmp = k; | ||
while (tmp < 0) { | ||
ans[i] += code[(i + tmp + len) % len]; | ||
tmp++; | ||
} | ||
} | ||
} | ||
|
||
return ans; | ||
} | ||
}; | ||
|
||
class Contest396 { | ||
public: | ||
bool isValid(string word) { | ||
if (word.size() < 3) return false; | ||
|
||
bool vowel = false; | ||
bool non_vowel = false; | ||
for (char c : word) { | ||
if (!((c - '0' >= 0 && c - '0' <= 9) || (c - 'a' >= 0 && c - 'a' < 26) || | ||
(c - 'A' >= 0 && c - 'A' < 26))) { | ||
return false; | ||
} | ||
|
||
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || | ||
c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U') { | ||
vowel = true; | ||
} else if ((c - 'a' >= 0 && c - 'a' < 26) || | ||
(c - 'A' >= 0 && c - 'A' < 26)) { | ||
non_vowel = true; | ||
} | ||
} | ||
if (vowel && non_vowel) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
}; |