当前位置: 首页>>代码示例>>C++>>正文


C++ Solution类代码示例

本文整理汇总了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;
}
开发者ID:whguo,项目名称:LeetCode,代码行数:6,代码来源:26.Remove+Duplicates+from+Sorted+Array.cpp

示例2: main

int main(int argc, const char * argv[]) {
    Solution test;
    cout << test.countAndSay(5) << endl;
    return 0;
}
开发者ID:halibut735,项目名称:leetcode,代码行数:5,代码来源:main.cpp

示例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); 
    }
开发者ID:yesyestian,项目名称:BNB-solver,代码行数:11,代码来源:multigo.hpp

示例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);
开发者ID:banyudu,项目名称:leetcode,代码行数:31,代码来源:test.cpp

示例5: main

int main() {
    Solution s;
    cout << s.combine(4, 2) << endl;
    return 0;
}
开发者ID:zsmountain,项目名称:leetcode,代码行数:5,代码来源:combinations.cpp

示例6: TEST

TEST(removeElement, test3) {
    Solution s;
    vector<int> nums = {3,3,3,3,3};
    EXPECT_EQ(s.removeElement(nums, 3), 0);
}
开发者ID:yuncliu,项目名称:Learn,代码行数:5,代码来源:RemoveElement.cpp

示例7: main

int main() {
    Solution s;
    vector<int> nums = {};
    cout << s.findPeakElement(nums) << endl;
    return 0;
}
开发者ID:zsmountain,项目名称:leetcode,代码行数:6,代码来源:find_peak_element.cpp

示例8: main

int main(int argc, char *argv[]){
    Solution sol;
    sol.solveNQueens(stoi(argv[1]));
    return 0;
}
开发者ID:cyongli,项目名称:code_bricker,代码行数:5,代码来源:102.cpp

示例9: main

int main() {
    vector<int> num = {100, 4, 200, 1, 3, 2};
    Solution sol;
    cout << sol.longestConsecutive(num) << endl;
    return 0;
}
开发者ID:1code,项目名称:leetcode2,代码行数:6,代码来源:LongestConsecutiveSequence.cpp

示例10: main

int main() {
    Solution solution;
    solution.isAdditiveNumber("111122335588143");
    return 0;
}
开发者ID:viing937,项目名称:leetcode,代码行数:5,代码来源:306.cpp

示例11: main

int main() {
    Solution solution;
    solution.integerBreak(20);
    return 0;
}
开发者ID:brickgao,项目名称:leetcode,代码行数:5,代码来源:Integer_Break.cpp

示例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", "")
{
开发者ID:gongzhitaao,项目名称:oj,代码行数:31,代码来源:315-count-of-smaller-numbers-after-self_test.cpp

示例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";
//.........这里部分代码省略.........
开发者ID:obiwandu,项目名称:OnlineJudgeSolution,代码行数:101,代码来源:WordSegmentation.cpp

示例14: main

int main(){
	Solution s;
	cout << s.removeDuplicateLetters("")<< endl;
	return 0;
}
开发者ID:Gavinthisisit,项目名称:Codes,代码行数:5,代码来源:Remove_Duplicate_Letters.cpp

示例15: main

int main() {
    Solution sol;
    vector<int> res = sol.getRow(3);
    for (int i : res) cout << i << " ";
    cout << endl;
}
开发者ID:vancexu,项目名称:LeetCode,代码行数:6,代码来源:pascals_triangle_II.cpp


注:本文中的Solution类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。