自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

luoyer的博客

算法设计与分析作业专用~(=@__@=)

  • 博客(20)
  • 收藏
  • 关注

原创 最后的证明:8.15

题目: 最大公共子图 证明如下问题是NP-完全的: 输入:两个图G1=(V,E)G_1=(V,E) 和 G2=(V,E)G_2=(V,E);预算b。 输出:两个节点集合V′1⊆V1V_1'\subseteq V_1 和 V′2⊆V2V_2'\subseteq V_2,他们被移除后,将在两图张分别留下至少b个节点,且图的剩余部分完全一样。证明:可以将最大独立集问题归约到此问题。

2017-07-03 00:19:51 493

原创 第十八周算法分析与设计: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 the two numbers and r

2017-06-28 16:08:37 244

原创 第十七周算法设计与分析:Minesweeper

问题描述: Let’s play the minesweeper game (Wikipedia, online game)! You are given a 2D char matrix representing the game board. ‘M’ represents an unrevealed mine,** ‘E’ represents an **unrevealed em

2017-06-21 00:03:23 500

原创 第十六周算法分析与设计:Generate Parentheses

问题描述: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: [ “((()))”, “(()())”, “

2017-06-11 20:30:20 294

原创 第十五周算法分析与设计:Count Numbers with Unique Digits

问题描述: Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Example: Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x

2017-06-04 15:17:04 250

原创 第十四周算法分析与设计:Binary Tree Preorder Traversal

问题描述: Given a binary tree, return the preorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Recursi

2017-05-26 23:41:34 419

原创 第十三周算法分析与设计:Kill Process

问题描述: Given n processes, each process has a unique PID (process id) and its PPID (parent process id). Each process only has one parent process, but may have one or more children processes. This

2017-05-21 14:54:00 363

原创 第十二周算法分析与设计: 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-11 19:01:38 234

原创 第十一周算法分析与设计: Sort Colors

问题描述: Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the in

2017-05-08 00:32:20 178

原创 第十周算法分析与设计: Find Bottom Left Tree Value

问题描述: Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input: 2 / \ 1 3 Output: 1 Example 2: Input:   1   / \

2017-05-01 00:10:49 306

原创 第九周算法分析与设计: Search for a Range

问题描述: Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm’s runtime complexity must be in the order of O(logn)O(log

2017-04-21 22:57:47 193

原创 第八周算法分析与设计:Permutation Sequence

算法描述: The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3): "123" "1

2017-04-15 21:22:22 219

原创 第七周算法分析与设计:ZigZag Conversion

算法描述: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N

2017-04-10 10:30:32 279

原创 第六周算法分析与设计Ⅱ: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.题目来自于此处(注:此题难度虽为easy,但感觉挺典型,很有代表性)解决方案1(非递归): 另起一个

2017-04-01 11:55:28 359

原创 第六周算法分析与设计Ⅰ:Remove Nth Node From End of List

算法描述: Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, andn = 2. After removing the second node from the end,

2017-04-01 11:48:14 254

原创 第五周算法分析与设计:Minimum Size Subarray Sum

算法描述: Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn’t one, return 0 instead. For example, give

2017-03-25 21:33:54 252

原创 第四周算法分析与设计: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 constant

2017-03-17 11:56:24 268

原创 第三周算法分析与设计:Search in Rotated Sorted Array

算法描述: 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). You are given a target value to search. If

2017-03-09 22:32:05 322

原创 第二周算法设计与分析:Search a 2D Matrix II

这周试一下markdown语法题目来自此处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 r

2017-03-03 16:56:06 200

原创 第一周算法设计与分析: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 linei is at (i, ai

2017-02-25 16:40:41 288

空空如也

空空如也

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

TA关注的人

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