自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 算法概论第八章练习题8.3

对于任意一个SAT问题的实例I,令I‘=(I, k)为吝啬SAT问题的一个实例,其中k=实例I的输入个数。 则对于吝啬SAT问题,实例I’若存在满足的赋值S’,那么S=S'也是SAT问题中实例I的满足赋值。 若实例I’不存在满足的赋值,则实例I也不存在满足的赋值 其中,实例I到实例I’的转换显然是多项式时间内的,且SAT问题是NP-完全问题。 因此,吝啬SAT也是NP-完全问题

2017-07-10 13:03:46 413

原创 Text Justification

Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You should pack your words in a greedy approach; that i

2017-06-19 00:18:23 308

原创 Divide Two Integers

Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 获得两个整数的商,不使用乘法、除法、取模操作。 如果结果越界,返回最大值。 首先是这已明确能使用的运算操作基本加和减了 然后是一个整数除以另一个整数结果绝

2017-06-17 16:46:22 437

原创 Valid Number

Validate if a given string is numeric. Some examples: "0" => true " 0.1 " => true "abc" => false "1 a" => false "2e10" => true Note: It is intended for the problem statement to be ambiguo

2017-06-16 15:14:17 392

原创 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, sums up t

2017-06-13 19:45:24 320

原创 Decode Ways

A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an encoded message containing digits, determine the total nu

2017-06-13 17:21:27 294

原创 Coin Change

You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money

2017-06-13 16:20:40 450

原创 Unique Paths

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the

2017-06-13 11:43:23 322

原创 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 front of t

2017-05-22 19:38:41 321

原创 Target Sum

You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol. Find out

2017-05-21 13:56:15 299

原创 Find Largest Value in Each Tree Row(找出一棵树每一行的最大值)

You need to find the largest value in each row of a binary tree. Example: Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9] 找出树

2017-05-20 21:11:23 556

原创 Search a 2D Matrix II(搜索一个二维矩阵)

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted in ascending from left to right.Integers in

2017-03-07 21:29:12 1105

原创 Merge k Sorted Lists(合并k个有序链)

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 合并K个有序链: 关于两个有序数组的合并方法就不多赘述了,就是合并排序中的合并过程。 那么对于k个有序链的合并有何不同呢? 个人感觉应该是指针的操作,除此之外和合并排序的合并过程并无

2017-03-06 23:22:14 331

原创 Median of Two Sorted Arrays(两个有序数组的中位数)

There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)) Example 1: nums1

2017-03-06 21:28:50 590

原创 Kth Largest Element in an Array(数组中第K大元素)

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, return 5.

2017-03-03 17:28:18 422

原创 Maximum Subarray(最大子序列)

Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2,1] ha

2017-03-03 15:46:42 423

空空如也

空空如也

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

TA关注的人

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