Example #1
0
int main(){
    Solution s;
    printList(s.partition(printList(buildList("")),3));
    printList(s.partition(printList(buildList("1")),3));
    printList(s.partition(printList(buildList("5")),3));
    printList(s.partition(printList(buildList("1,4,3")),3));
    printList(s.partition(printList(buildList("1,4,3,2,5,2")),3));
}
int main() {
    Solution so;
    printList(so.partition(nullptr, 1));
    printList(so.partition(createList({0}), 1));
    printList(so.partition(createList({1, 0}), 1));
    printList(so.partition(createList({0, 4, 1, 0, 1, 2, 3}), 1));
    printList(so.partition(createList({ 1, 4, 3, 2, 5, 2 }), 3));
}
Example #3
0
int main() {
    //1->4->3->2->5->2
    ListNode node1(1);
    ListNode node2(4);
    ListNode node3(3);
    ListNode node4(2);
    ListNode node5(5);
    ListNode node6(2);

    node1.next = &node2;
    node2.next = &node3;
    node3.next = &node4;
    node4.next = &node5;
    node5.next = &node6;

    Solution s;
    ListNode *p;
    p = s.partition(&node1, 3);

    while(p) {
        cout << p->val << "->"; 
        p = p->next;
    }

    ;
}
Example #4
0
int main() {
	string s ("ab");
	Solution solution;
	vector<vector<string> > result = solution.partition(s);
	cout << result.size() << endl;
	return 1;
}
Example #5
0
int main(){
	ListNode *head=new ListNode(1);
	head->next=new ListNode(1);
	Solution a;
	head=a.partition(head,0);
	while(head!=NULL) {cout<<head->val<<endl;head=head->next;}
}
void test()
{
	Solution sol;
	ListNode* head = CreateList({ 1,3,5,6,2,4 });
	ListNode* ret = sol.partition(head, 3);
	PrintList(ret);
}
Example #7
0
int main(){
    string s = "fifgbeajcacehiicccfecbfhhgfiiecdcjjffbghdidbhbdbfbfjccgbbdcjheccfbhafehieabbdfeigbiaggchaeghaijfbjhi";
	//string s = "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab";
    Solution sol;
    sol.partition(s);
    return 0;
}
Example #8
0
int main()
{
	int src[][3]=
	{
	{9,9,0},
	{1,0,5},
	{2,5,6}
	};
	string start("hit");
	string end=("cog");
	string dict1[]={"hot","dot","dog","lot","log"};
	string str="aab";
	
	Solution s;
	vector<vector<string> >result=s.partition(str);
	int count=result.size();
	while(count--)
	{
		int count1=result[count].size();
		while(count1--)
			cout<<result[count][count1]<<" ";
		cout<<endl;
	}
	//s.ladderLength(start,end,dict);
	return 0;
}
void let_86(){
	ifstream fin;
	fin.open("let_86.txt");
	char tempc;
	int value;
	ListNode* head;
	ListNode*temp=NULL;
	while(fin.peek()!=']'){
		fin>>tempc>>value;
		ListNode* cur=(ListNode*) new ListNode(value);
		if(temp){
			temp->next=cur;
			temp=cur;
		}else{
			temp=cur;
			head=cur;
		}
	}
	Solution sol;
	temp=sol.partition(head,2);
	while(temp){
		cout<<temp->val<<",";
		temp=temp->next;
	}
	cout<<endl;
}
Example #10
0
int main()
{
    Solution s;
    ListNode* ret;

    ListNode n1(1);
    ListNode n2(4);
    ListNode n3(3);
    ListNode n4(2);
    ListNode n5(5);
    ListNode n6(2);

    n1.next = &n2;
    n2.next = &n3;
    n3.next = &n4;
    n4.next = &n5;
    n5.next = &n6;

    ret = s.partition(&n1, 3);

    while (ret) {
        cout << ret->val << ",";
        ret = ret->next;
    }
    cout << endl;
}
Example #11
0
void main()
{
	Solution mySolu;
	ListNode* Head1 = new ListNode(1);
	ListNode* Node1 = new ListNode(4);
	ListNode* Node2 = new ListNode(3);
	ListNode* Node3 = new ListNode(2);
	ListNode* Node4 = new ListNode(5);
	ListNode* Node9 = new ListNode(2);
	
	ListNode* Head2 = new ListNode(1);
	ListNode* Node5 = new ListNode(3);
	ListNode* Node6 = new ListNode(5);
	ListNode* Node7 = new ListNode(7);
	ListNode* Node8 = new ListNode(9);
	
	mySolu.ListAdd(Head1, mySolu.ListAdd(Node1, mySolu.ListAdd(Node2, mySolu.ListAdd(Node3, mySolu.ListAdd(Node4, Node9)))));
	//ListAdd(Head2, ListAdd(Node5, ListAdd(Node6, ListAdd(Node7, Node8))));
	PrintList(Head1);
	//PrintList(Head2);
	Head1 = mySolu.partition(Head1,3);
	PrintList(Head1);


}
int main(int argc, char * argv[]) {
    Solution solve;
    vector<vector<string> > ans = solve.partition("aab");
    UIO<string>::pr(ans);

    return 0;
}
Example #13
0
int main(int argc, char *argv[])
{
	freopen("./input.txt", "r", stdin);
	Solution poSolution;

	int testcase = 0;
	scanf("%d", &testcase);
	char str[128];
	getchar();

	while (testcase--)
	{
		gets(str);

		vector<vector<string> > res = poSolution.partition(str);
		printf("======RES for [%s]\n", str);
		for (size_t i = 0; i < res.size(); ++i)
		{
			for (size_t j = 0; j < res[i].size(); ++j)
			{
				printf("%s ", res[i][j].c_str());
			}
			printf("\n");
		}
	}

	return 0;
}
Example #14
0
int main()
{
    Solution sln;
    string s="aab";
    sln.partition(s);
    system("pause");
    return 0;
}
int main() {
    ofstream fout("sol.out");
    ifstream fin("sol.in");

    Solution sol;
    sol.partition("a");
    return 0;
}
Example #16
0
int main() {
  ListNode *head = CreateList();
  Solution s;
  head = s.partition(head, 3);
  for (; head != NULL; head = head->next)
    cout << head->val << "->";
  cout << "NULL" << endl;
}
int main() {
    Solution test;
    ListNode *head;
    head = createLinklist();
    printList(head);
    head = test.partition(head, 3);
    printList(head);
    return 0;
}
Example #18
0
int main()
{
    Solution s;
    vector<string> v;
    v.push_back("a");
    vector<vector<string>> vv;
    vv.push_back(v);

    s.partition("ab");
}
Example #19
0
int main() {
    Solution *s = new Solution();
    ListNode *l1 = new ListNode(1);
    l1 = insert(l1, 1);
    print(l1);
    ListNode* r = s->partition(l1, 0);
    print(r);

    return 0;
}
int main() {
    Solution solution;
    vector<vector<string> > result = solution.partition("aabbbb");
    for (int i = 0; i < (int) result.size(); i ++) {
        for (int j = 0; j < (int) result[i].size(); j ++) {
            cout << result[i][j] << " ";
        }
        cout << endl;
    }
}
Example #21
0
int main(int argc, const char * argv[]) {
    ListNode node1 = ListNode(1);
    ListNode node2 = ListNode(2);
    ListNode node3 = ListNode(3);
    node1.next = &node2;
    node2.next = &node3;
    ListNode *head = &node1;
    Solution sl;
    head = sl.partition(head, 3);
    return 0;
}
Example #22
0
int main() {
  Solution sol;
  int i, j;
  vector<vector<string> > result = sol.partition("amanaplanacanalpanama"); 
  for (i = 0; i < result.size(); i++) {
    for (j = 0; j < result[i].size(); j++) 
      std::cout << result[i][j] << "  ";
    std::cout << std::endl;
  }
  return 0;
}
int main(int argc, const char *argv[]) {
    Solution s;
    std::vector<std::vector<std::string>>&& result = s.partition("aab");
    for (auto& vec : result) {
        for (auto& str : vec) {
            std::cout << str << ' ';
        }
        std::cout << std::endl;
    }
    return 0;
}
int main() {
    string str;
    Solution s;
    cin >> str;
    vector<vector<string>> res = s.partition(str);
    for (auto &x : res) {
        for (auto &y : x)
            cout << y << ' ';
        cout << endl;
    }
    return 0;
}
Example #25
0
int main(){
	string s;
	cout << "s = "; cin >> s;
	Solution soln;
	vector<vector<string>> result = soln.partition(s);
	for(unsigned int i = 0; i < result.size(); i++){
		for(unsigned int j = 0; j < result[i].size(); j++){
			cout << result[i][j] << " ";
		}
		cout << endl;
	}
}
Example #26
0
int main(){
    Solution s;
    ListNode* head = new ListNode(2);
    ListNode* a = new ListNode(1);
    head->next = a;
    head = s.partition(head,2);
    while(head != NULL){
        cout<<head->val<<endl;
        head = head->next;
    }
    return 0;
}
Example #27
0
int main(void)
{
	ListNode *l1=NULL,*l2=NULL;
	Solution mysolution;
	int a[]={1,4,3,2,5,2};

	CreateList(&l1,a,(int)sizeof(a)/sizeof(*a));

	PrintList(mysolution.partition(l1,3));
	
	return 1;
}
Example #28
0
int main()
{
    Solution solve;
    auto result=solve.partition("aab");
    for(auto item:result)
    {
       for(auto sub:item)
         cout<<sub<<" ";
       cout<<"\n";
    }
    return 0;
}
int main()
{
    string str = "aab";
    Solution s;
    vector<vector<string> > results = s.partition(str);
    for (int i = 0; i < results.size(); ++i)
    {
        for (int j = 0; j < results[i].size(); ++j)
            cout<<results[i][j]<<" ";
        cout<<endl;
    }
    return 0;
}
int main() {
	Solution a;
	vector<vector<string> > re = a.partition("aa");
	for (int i = 0; i < re.size(); ++i)
	{
		vector<string> tmp = re[i];
		for (int j = 0; j < tmp.size(); ++j) {
			cout<<tmp[j]<<" "; 
		}
		cout<<endl;
	}
	return 0;
}