本文整理汇总了C++中Solution类的典型用法代码示例。如果您正苦于以下问题:C++ Solution类的具体用法?C++ Solution怎么用?C++ Solution使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Solution类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Solution s;;
vector<int> nums{ 1, 3 , 3 , 5 , 5 ,8 , 8 ,9};
cout<<s.removeDuplicates(nums)<<endl;
}
示例2: main
int main(int argc, const char * argv[]) {
Solution test;
cout << test.countAndSay(5) << endl;
return 0;
}
示例3: merge
/**
* Merging two solutions. The result is stored in the first solution.
*
* @param first first solution
* @param second second solution
*/
void merge(Solution& first, Solution& second)
{
for(std::vector<Point>::iterator i = second.mPoints.begin(); i != second.mPoints.end(); i ++)
first.pushPoint(*i);
}
示例4: TEST_CASE
#define CATCH_CONFIG_MAIN
#define CATCH_CONFIG_COLOUR_NONE
#include <catch.hpp>
#include "solution.cpp"
Solution sln;
TEST_CASE("normal values", "[Solution]")
{
REQUIRE(sln.isAnagram("abc", "cba") == true);
REQUIRE(sln.isAnagram("abc", "cab") == true);
REQUIRE(sln.isAnagram("abc", "ca") == false);
}
TEST_CASE("empty values", "[Solution]")
{
REQUIRE(sln.isAnagram("abc", "") == false);
REQUIRE(sln.isAnagram("", "abc") == false);
REQUIRE(sln.isAnagram("", "") == true);
}
TEST_CASE("same characters", "[Solution]")
{
REQUIRE(sln.isAnagram("aaa", "aab") == false);
REQUIRE(sln.isAnagram("aaa", "aaa") == true);
REQUIRE(sln.isAnagram("aba", "baa") == true);
}
TEST_CASE("long strings", "[Solution]")
{
REQUIRE(sln.isAnagram("qwertyuiopasdfghjklzxcvbnm", "zxcvbnmasdfghjklqwertyuiop") == true);
示例5: main
int main() {
Solution s;
cout << s.combine(4, 2) << endl;
return 0;
}
示例6: TEST
TEST(removeElement, test3) {
Solution s;
vector<int> nums = {3,3,3,3,3};
EXPECT_EQ(s.removeElement(nums, 3), 0);
}
示例7: main
int main() {
Solution s;
vector<int> nums = {};
cout << s.findPeakElement(nums) << endl;
return 0;
}
示例8: main
int main(int argc, char *argv[]){
Solution sol;
sol.solveNQueens(stoi(argv[1]));
return 0;
}
示例9: main
int main() {
vector<int> num = {100, 4, 200, 1, 3, 2};
Solution sol;
cout << sol.longestConsecutive(num) << endl;
return 0;
}
示例10: main
int main() {
Solution solution;
solution.isAdditiveNumber("111122335588143");
return 0;
}
示例11: main
int main() {
Solution solution;
solution.integerBreak(20);
return 0;
}
示例12: TEST_CASE
#include <vector>
#include <algorithm>
using namespace std;
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include "315-count-of-smaller-numbers-after-self.cpp"
TEST_CASE("1 element", "")
{
Solution s;
vector<int> vec = {0}, tar = {0};
CHECK(s.countSmaller(vec) == tar);
vec = {1};
CHECK(s.countSmaller(vec) == tar);
}
TEST_CASE("2 elements", "")
{
Solution s;
vector<int> vec = {0, 0}, tar = {0, 0};
CHECK(s.countSmaller(vec) == tar);
vec = {1, 0}, tar = {1, 0};
CHECK(s.countSmaller(vec) == tar);
}
TEST_CASE("Random", "")
{
示例13: main
int main()
{
/*special*/
{
//tr1::unordered_set<string> dict = {"lint", "code"};
tr1::unordered_set<string> dict;
string s = "lintcodeisawesome";
Solution sol;
cout << "no1 ";
if (!sol.wordSegmentation(s, dict))
{
cout << "correct!" << endl;
}
else
{
cout << "wrong!" << endl;
}
}
{
//tr1::unordered_set<string> dict = {"lint", "code"};
tr1::unordered_set<string> dict;
dict.insert("awesome");
dict.insert("is");
dict.insert("lint");
dict.insert("code");
string s = "";
Solution sol;
cout << "no2 ";
if (sol.wordSegmentation(s, dict))
{
cout << "correct!" << endl;
}
else
{
cout << "wrong!" << endl;
}
}
{
//tr1::unordered_set<string> dict = {"lint", "code"};
tr1::unordered_set<string> dict;
string s = "";
Solution sol;
cout << "no21 ";
if (sol.wordSegmentation(s, dict))
{
cout << "correct!" << endl;
}
else
{
cout << "wrong!" << endl;
}
}
/*positive*/
{
//tr1::unordered_set<string> dict = {"lint", "code"};
tr1::unordered_set<string> dict;
dict.insert("a");
string s = "a";
Solution sol;
cout << "no3 ";
if (sol.wordSegmentation(s, dict))
{
cout << "correct!" << endl;
}
else
{
cout << "wrong!" << endl;
}
}
{
//tr1::unordered_set<string> dict = {"lint", "code"};
tr1::unordered_set<string> dict;
dict.insert("awesome");
dict.insert("is");
dict.insert("lint");
dict.insert("code");
string s = "lintcodeisawesome";
Solution sol;
cout << "no4 ";
if (sol.wordSegmentation(s, dict))
{
cout << "correct!" << endl;
}
else
{
cout << "wrong!" << endl;
}
}
{
//tr1::unordered_set<string> dict = {"lint", "code"};
tr1::unordered_set<string> dict;
dict.insert("lint");
dict.insert("lint");
dict.insert("code");
string s = "lintcode";
//.........这里部分代码省略.........
示例14: main
int main(){
Solution s;
cout << s.removeDuplicateLetters("")<< endl;
return 0;
}
示例15: main
int main() {
Solution sol;
vector<int> res = sol.getRow(3);
for (int i : res) cout << i << " ";
cout << endl;
}