摘要: 题面 Given a linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nodes, only nodes itself may be 阅读全文
posted @ 2019-05-16 21:42 yocichen 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 题面 Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses 给定int n,代表n组括号,编码生成所有有效的括号组合(即符合括号嵌套规则) 样例 g 阅读全文
posted @ 2019-05-16 11:58 yocichen 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 题面 删除倒数第n个节点,可以保证给定的n有效。 样例 Note: Given n will always be valid. 思路 这个题,挺经典的题目。我们使用快慢指针解决,即:一个指针先行n, 之后另一个指针跟它一起走,直到后面的指针到链表尾部,结束,返回结果。 分析样例 n = 2 算法 1 阅读全文
posted @ 2019-05-16 10:33 yocichen 阅读(126) 评论(0) 推荐(0) 编辑