摘要:
题目描述: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra sp 阅读全文
posted @ 2016-07-05 00:40
godlei
阅读(152)
评论(0)
推荐(0)
摘要:
题目描述: 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 阅读全文
posted @ 2016-07-05 00:39
godlei
阅读(461)
评论(0)
推荐(0)
摘要:
题目描述: Given a linked list, swap every two adjacent nodes and return its head. 解题分析: 解题思路很简单,就是先两两扫描,然后调换顺序即可。这道题的难点在于每个节点的next域指向问题,所以解这样的题最好可以在纸上写一下交 阅读全文
posted @ 2016-07-05 00:37
godlei
阅读(251)
评论(0)
推荐(0)
摘要:
题目描述: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 解题分析: 解题思路很简单,就是先两两排序,不断减小链表数量,最后将所有数组织成一个有序链 阅读全文
posted @ 2016-07-05 00:34
godlei
阅读(200)
评论(0)
推荐(0)
摘要:
题目描述: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. 解题分析: 这类题一般都要用递归的方法来解决。需要设两个集合类分别存储待匹配的( 阅读全文
posted @ 2016-07-05 00:31
godlei
阅读(173)
评论(0)
推荐(0)
摘要:
题目描述: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 解题 阅读全文
posted @ 2016-07-05 00:29
godlei
阅读(147)
评论(0)
推荐(0)
摘要:
题目描述: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close i 阅读全文
posted @ 2016-07-05 00:26
godlei
阅读(329)
评论(0)
推荐(0)
摘要:
题目描述: Given a linked list, remove the nth node from the end of list and return its head. 解题分析: 这个题的关键是找到倒数第n个节点:设置两个标记变量,想让其中1个走n-1步,然后两个一起往后走,当第一个变量指 阅读全文
posted @ 2016-07-05 00:24
godlei
阅读(196)
评论(0)
推荐(0)
摘要:
题目描述: Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the arra 阅读全文
posted @ 2016-07-05 00:22
godlei
阅读(181)
评论(0)
推荐(0)
摘要:
题目描述: Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. 解题分析: 这种类型的题必然要用位运算,虽然自己写了关于位运算的代码,但是不够简洁。 后来参考了 阅读全文
posted @ 2016-07-05 00:19
godlei
阅读(244)
评论(0)
推荐(0)
摘要:
题目描述: Given a digit string, return all possible letter combinations that the number could represent. 解题分析: 回溯法的典型应用,用一个数据结构表示出按键与其表示字母的对应关系,直接用回溯法做即可。 阅读全文
posted @ 2016-07-05 00:17
godlei
阅读(161)
评论(0)
推荐(0)

浙公网安备 33010602011771号