自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 吝啬SAT问题

问题描述: 吝啬SAT问题是这样的:给定一组子句(每个子句都是其中文字的析取)和整数k,求一个最多有k个变量为true的满足赋值——如果该赋值存在。证明吝啬问题是NP-完全问题。为了帮助理解这个问题,我们写解释下什么是SAT问题假设我们有这样一组子句: (a⋃b⋃c)⋂(a⋃b¯)⋂(b⋃c¯)(a¯⋂c)⋂(a¯⋃b¯⋃c¯)(a\bigcup b\bigcup c)\bigcap(a\bi

2017-06-07 21:27:49 550

原创 Search Insert Position

问题描述:Search Insert Position Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may

2017-05-27 15:35:17 171

原创 Remove Duplicates from Sorted Array

问题描述:Remove Duplicates from Sorted Array 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 space fo

2017-05-27 12:02:55 223

原创 Merge Two Sorted Lists

问题描述:Merge Two Sorted Lists 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.思路:对于两个list而言,我们需要找到按照大

2017-05-27 11:16:30 167

原创 Longest Common Prefix

问题描述:Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings.思路:在这个问题中,我们要找到所有字符串的公共前缀,最简单的方法就是从第一个字符串的第一位开始往后取,直到找到最大的公共字符串为止,那么这个条件是啥呢?第一个条件是当公共

2017-05-27 10:18:18 184

原创 Container With Most Water

Container With Most Water问题描述: Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i

2017-05-26 18:18:53 139

原创 Palindrome Number

Palindrome Number问题描述: Determine whether an integer is a palindrome. Do this without extra space.思路:这个问题需要注意的第一个问题是不能使用额外的空间,也就是说我们可以在反转字符串一半的时候进行判断。接下来要注意的问题有那么几个,一个是负数不是回文数,个位数也不是回文数,然后我们用一个whille

2017-05-26 16:18:20 147

原创 Integer to Roman

问题描述:Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.思路:首先先学习一下罗马数字的规则,然后再建立4个数组,每个数组表示罗马数字的每一位,然后我们只用把数字取模就可以得到各个罗马数字的

2017-05-26 11:54:38 277

原创 Swap Nodes in Pairs

问题描述: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only c

2017-05-18 10:19:42 161

原创 Find the Difference

问题描述:Find the Difference Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at a random position.

2017-05-15 16:48:25 290

原创 Maximum Depth of Binary Tree

问题描述:Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

2017-05-15 15:17:57 168

原创 String to Integer (atoi)

问题描述:String to Integer (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

2017-03-27 18:28:57 161

原创 Longest Substring Without Repeating Characters

问题描述:Longest Substring Without Repeating Characters Given a string, find the length of the longest substring without repeating characters. Examples: Given “abcabcbb”, the answer is “abc”

2017-03-27 17:05:54 161

原创 Add Two Numbers

问题描述:Add Two Numbers You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add

2017-03-27 15:20:24 139

原创 Two Sum

问题描述:Two Sum Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and y

2017-03-27 13:48:11 146

原创 Single NumbererⅢ

题目描述:Single NumbererⅡ Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note: Your algorithm should have a linear ru

2017-03-21 21:35:39 278

原创 Single NumbererⅡ

题目描述:Single NumbererⅡGiven an array of integers, every element appears three times except for one, which appears exactly once. Find that single one.Note: Your algorithm should have a linea

2017-03-21 15:51:25 236

原创 Single Number

问题描述:Single Number Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you imp

2017-03-19 18:35:32 149

原创 Ugly Number II

问题描述:Ugly Number II Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is th

2017-03-19 15:14:42 187

原创 Ugly Number

题目描述:Ugly Number Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly whil

2017-03-05 18:54:47 141

原创 Roman to Integertegerer

问题描述:Roman to IntegerGiven a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.首先我们需要对罗马数字有一个基本的了解,大家都知道罗马数字1到9分别I,1II,2III,

2017-03-05 14:37:56 196

空空如也

空空如也

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

TA关注的人

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