摘要:
Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()()"典型的递归。一步步构造字符串。当左括号出现次数 generateParenthesis(int n) { 3 // S 阅读全文
摘要:
Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct order,"()"and"()[]{}"are all valid but"(]"and"([)]"are not.思路: 阅读全文
摘要:
Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5.思路:两个指针,未能一次通过。。。。当需删除的元素是第一个元素时,直接按24-27进行删除 1 /** 2 * Defin 阅读全文