摘要:All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to 阅读全文
LeetCode 187. Repeated DNA Sequences 20170706 第三十次作业
2017-07-06 17:41 by 方小呆dai, 177 阅读, 0 推荐, 收藏, 编辑LeetCode 162. Find Peak Element 20170706
2017-07-06 17:11 by 方小呆dai, 186 阅读, 0 推荐, 收藏, 编辑
摘要:A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its inde 阅读全文
LeetCode 153. Find Minimum in Rotated Sorted Array 20170706
2017-07-06 16:25 by 方小呆dai, 175 阅读, 0 推荐, 收藏, 编辑
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find 阅读全文
LeetCode 144. Binary Tree Preorder Traversal 20170706
2017-07-06 11:30 by 方小呆dai, 131 阅读, 0 推荐, 收藏, 编辑
摘要:Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [1,2,3]. Note: Recursive solu 阅读全文
LeetCode 142. Linked List Cycle II 20170706
2017-07-06 11:12 by 方小呆dai, 130 阅读, 0 推荐, 收藏, 编辑
摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. 题目大意:给定一个链表,如果该链表 阅读全文
LeetCode 134. Gas Station 20170706
2017-07-06 10:40 by 方小呆dai, 187 阅读, 0 推荐, 收藏, 编辑
摘要:There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it cost 阅读全文
LeetCode 131. Palindrome Partitioning 20170706
2017-07-06 09:28 by 方小呆dai, 138 阅读, 0 推荐, 收藏, 编辑
摘要:Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For exampl 阅读全文
LeetCode 120. Triangle 20170706 部分之前做了没写的题目
2017-07-06 09:02 by 方小呆dai, 155 阅读, 0 推荐, 收藏, 编辑
摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the fo 阅读全文
算法概论课后习题8.8
2017-07-06 00:42 by 方小呆dai, 212 阅读, 0 推荐, 收藏, 编辑
摘要:题目:在精确的4SAT(EXACT 4SAT)问题中,输入为一组子句,每个子句都是恰好4个文字的析取,且每个变量最多在每个子句中出现一次。目标是求它的满足赋值——如果该赋值存在。证明精确的4SAT是NP-完全问题。 跟8.3题类似,要证明精确的4SAT问题是NP-完全问题分两步: 1、精确的4SAT 阅读全文
算法概论第八章课后习题8.3
2017-07-05 22:50 by 方小呆dai, 224 阅读, 0 推荐, 收藏, 编辑
摘要:8.3 吝啬SAT问题是这样的:给定一组子句(每个子句都是其中文字的析取)和整数k,求一个最多有k个变量为true的满足赋值——如果该赋值存在。证明吝啬SAT是NP-完全问题。 证明: 补充一下SAT问题的概念:SAT问题是指是否存在一组对所有布尔变量的赋值(TRUE或FALSE),使得整个合取范式 阅读全文