自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(19)
  • 收藏
  • 关注

原创 【算法概论习题】8.8解答

题目:  在精确的4SAT(EXACT 4SAT)问题中,输入为一组子句,每个字句都是恰好4个文字的析取,且每个变量最多在每个子句中出现一次。目标是求它的满足赋值——如果该赋值存在。证明精确的4SAT是NP-完全问题。解答:在证明精确的4SAT问题是NP-完全问题前,先得证明其属于NP问题。因为EXACT 4SAT和SAT相同,在多项式时间内可以显然地给出一个解得以验证,所以我

2017-07-13 12:08:15 403

原创 题解:Gray Code

题目:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the seq

2017-06-11 15:33:59 314

原创 题解:Binary Tree Inorder Traversal

题目:Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2].Note: Recur

2017-06-11 14:17:53 312

原创 题解:Surrounded Regions

题目如下:Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For e

2017-06-04 16:06:23 293

原创 题解:Bitwise AND of Numbers Range

题目如下:Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4.如果单纯循环会超时,这是因为有许多不必要的按位与操作。注意到0和任意与都是0,而n和n-1相与能去掉最后一个1(二进制下),解决代码如下:int rangeBitwiseAnd(int

2017-05-28 21:50:11 385

原创 题解:Queue Reconstruction by Height

题目如下:Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in

2017-05-21 14:21:08 330

原创 题解:Remove Invalid Parentheses

题目如下:Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.Note: The input string may contain letters other than the parenthes

2017-05-14 23:00:53 690

原创 题解:Repeated DNA Sequences

题目如下: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 identify repeated sequences within the

2017-05-06 22:27:39 265

原创 题解:Perfect Squares

题目如下:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4

2017-04-30 21:41:26 299

原创 题解:Trapping Rain Water

题目如下:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1

2017-04-22 23:29:34 220

原创 题解:3Sum Closest

题目:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would hav

2017-04-16 17:14:23 262

原创 题解:triangle

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 following triangle[ [2], [3,4], [

2017-04-10 00:49:36 320

原创 题解:String to Integer (atoi)

自己来编写一个atoi函数,但是要考虑一些细节,先列出问题:Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask you

2017-04-02 13:40:08 260

原创 题解:Continuous Subarray Sum

题目:Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to the multiple of k, that is,

2017-03-26 20:37:34 305

原创 题解:Regular Expression Matching

题目:Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire

2017-03-26 20:02:06 304

原创 题解:Find Largest Value in Each Tree Rowt

题目:Find Largest Value in Each Tree RowYou need to find the largest value in each row of a binary tree.Example:Input: 1 / \ 3 2 / \ \ 5 3

2017-03-21 00:29:45 244

原创 Sort Characters By Frequency 题解

题目如下:Given a string, sort it in decreasing order based on the frequency of characters.Example:Input:"tree"Output:"eert"Explanation:'e' appears twice while 'r' and 't' both appear once

2017-03-12 10:17:24 365

原创 题解:Kth Largest Element in an Array

题目如下:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k = 2,

2017-03-05 15:39:43 382

原创 简单的string问题解决:Detect Capital

直接列出题目如下:Given a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of the following cases holds:A

2017-02-25 20:54:04 390

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除