自定义博客皮肤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)
  • 收藏
  • 关注

原创 Task Scheduler

问题:Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks.Tasks could be done without original order. Each task

2017-07-12 08:12:44 205

原创 Combination Sum

问题:Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may b

2017-07-12 01:26:08 307

原创 8.14 证明如下问题是NP完全的

8.14 给定一个无向图G =(V,E)和整数k,求G中一个规模为k的团以及一个规模为k的独立集。假定它们都是存在的。解析:在这个问题中,我们所要求的G中一个规模为k的团就是求图G中k的顶点,使得这些顶点之间两两都存在相连的边。我们首先假设要求任意图G(V,E)中大小为k的团,以此为基础的情况下,可以在此图G中添加k个相互独立的顶点,得到的一个新的图G'。在G'中 ,这k个相互独立

2017-07-12 01:05:57 1145

原创 Maximum Product of Three Numbers

Given an integer array, find three numbers whose product is maximum and output the maximum product.Example 1:Input: [1,2,3]Output: 6 Example 2:Input: [1,2,3,4]Output: 24代码: int ma

2017-07-10 15:13:59 181

原创 8.15最大公共子图

8.15最大公共子图:证明如下问题是NP-完全的:输入:两个图G1=(V1,E1)和G2=(V2,E2)输出:两个节点集合V1’和V2'分别是V1和V2的子集,它们被移除后,将在两图中分别留下至少b个节点,且图的剩余部分完全一样解析:即我们现在有两个图G1 G2,去掉一些定点V1'和V2‘之后’两个图都得到结点数至少为b的子图,且两个子图完全相同。首先我们先证明其实NP

2017-07-10 13:04:06 2018

原创 negative

问题:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321我觉得这个问题要解决的思路就是分情况来讨论,如果说x为0,则返回x,如果x为负的,则吧x转化为0-x在运算,当然还需要注意防止溢出,我一开始就忘了防溢出,后面才加上。然后在用正

2017-06-20 13:37:05 244

原创 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] 

2017-06-05 13:25:05 102

原创 Merge Sorted Array

问题:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.代码:class Solution {public:    void merge(vector& nums1, int m, vector& nums2, int n) { 

2017-05-31 20:12:22 160

原创 Remove Element

问题:Given an array and a value, remove all instances of that value in place and return the new length.解析:#include using namespace std;class Solution {public:int removeElement(int a[], int

2017-05-22 23:34:11 102

原创 Submission Details

问题:Determine whether an integer is a palindrome. Do this without extra space.代码:class Solution {public:    bool isPalindrome(int x) {         if(x            return false;       

2017-05-16 11:38:06 189

原创 Happy Number

Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares o

2017-05-06 10:40:23 139

原创 Factorial Trailing Zeroes

问题:Given an integer n, return the number of trailing zeroes in n!.Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time compl

2017-05-02 13:50:53 118

原创 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.代码:class Solution {  public:      List

2017-04-23 11:18:43 125

原创 Two Sum II - Input array is sorted

Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two number

2017-04-08 13:17:45 104

原创 Single Number

问题:Given an array of integers, every element appears twice except for one. Find that single one.代码:class Solution {public:    int singleNumber(vector& nums) {        int n = nums.size(

2017-03-27 11:06:43 137

原创 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 assume no duplicates in t

2017-03-18 21:35:19 123

原创 Length of Last Word

问题:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: 

2017-03-13 11:24:36 133

原创 Add Binary

学号:15337003姓名:段晓巍 问题:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".answer:#include#includeclass Solution {publ

2017-03-06 10:17:14 141

原创 Add to 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

2017-02-24 18:10:30 264

空空如也

空空如也

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

TA关注的人

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