码迷,mamicode.com
首页 >  
搜索关键字:swap nodes in pairs    ( 8848个结果
[snippet] get parameter
function(name) { var query=location.search.substring(1); var pairs=query.split("&"); for(var i=0;i<pairs.length;i++) ...
分类:其他好文   时间:2014-05-19 10:43:27    阅读次数:266
快速排序
void quickSort(int *a1 , int *a2){ int i=0 , j=a2-a1-1; if (i>=j) return; swap(a1[0] , a1[rand()%j+1]); while( ia1[0]) --j; if(i<j)...
分类:其他好文   时间:2014-05-19 07:43:47    阅读次数:213
使用引用交换两个数字
#include using namespace std; //定义一个函数,用于交换两个变量的值 void swap(int &a, int &b); void main() { int i = 3, j = 5; cout<<"交换前:i="<<i<<" j="<<j<<endl; swap(i,j); cout<<"交换后:i="<<i<<" j="<<j<<endl;...
分类:其他好文   时间:2014-05-18 16:05:54    阅读次数:209
LeetCode: Reverse Nodes in k-Group [024]
【题目】 Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. You may not alter the values in the nodes, only n...
分类:其他好文   时间:2014-05-18 10:22:34    阅读次数:367
LeetCode--Binary Tree Level Order Traversal
Binary Tree Level Order Traversal  Total Accepted: 12441 Total Submissions: 40879My Submissions Given a binary tree, return the level order traversal of its nodes' values. (ie, from left t...
分类:其他好文   时间:2014-05-18 10:11:13    阅读次数:337
LeetCode: Generate Parentheses [021]
【题目】 Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: "((()))", "(()())", "(())()", "()(())", "()()()" 【题意】 给定n对括号,输出所有可行的括号组合字符串。所谓合法,就是可以Valid Pare...
分类:其他好文   时间:2014-05-18 09:06:41    阅读次数:266
LeetCode: Merge k Sorted Lists [022]
【题目】 Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 【题意】 合并K个有序链表 【思路】 归并 Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For ...
分类:其他好文   时间:2014-05-18 09:05:40    阅读次数:255
LeetCode: Swap Nodes in Pairs [023]
【题目】 Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. You may not modify the values in the list, only nodes it...
分类:其他好文   时间:2014-05-18 08:37:57    阅读次数:370
Leetcode | Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the o...
分类:其他好文   时间:2014-05-18 02:34:57    阅读次数:352
Leetcode | Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then le...
分类:其他好文   时间:2014-05-18 01:53:53    阅读次数:331
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!