This file contains hidden or 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 Solution { | |
| public: | |
| int maxDifference(string s, int k) { | |
| int maxDiff = INT_MIN; | |
| int n = s.size(); | |
| for (int win = k; win <= n; ++win) { | |
| unordered_map<char, int> freq; | |
| for (int i = 0; i < win; ++i) { |
This file contains hidden or 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
| #include <iostream> | |
| #include <unordered_map> | |
| #include <climits> | |
| #include <string> | |
| using namespace std; | |
| int maxDiffEvenOddFreq(const string& s) { | |
| unordered_map<char, int> freq; | |
| // Count frequency of each character |
This file contains hidden or 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 Solution { | |
| public: | |
| int findKthNumber(int n, int k) { | |
| long long node = 1; | |
| for (int i = 1; i <= k; i++) { | |
| if (i == k) { | |
| return node; | |
| } | |
| if (node * 10 <= n) { |