自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 JavaScript 懒加载

JavaScript 懒加载懒加载,顾名思义,就是不急慢慢来,等迫不得已的时候再加载;在网页刚打开时,很可能因为请求太多而一时拥塞,并且习惯性的在body后有JavaScript脚本,这样一来就容易发生页面卡顿或崩溃等问题;所以我们可以采取动态加载的方式来让请求变得稀疏;原理:浏览器遇到src属性会阻塞渲染树,先下载内容,如果是脚本的话还会运行;先将img标签中的src链接设为同一...

2018-09-20 19:01:59 547

原创 浅谈JavaScript作用域

浅谈JavaScript作用域目录浅谈JavaScript作用域词法作用域和动态作用域声明提升块级作用域作用域的问题是任何一门语言必须弄清的问题之一,作为一个初学者,我希望通过这篇博客对我所学的知识做一个总结,有不对或者不清楚的地方还请不吝赐教词法作用域和动态作用域词法作用域也可以理解为静态作用域,也就是当你打出代码的时候就决定了作用域;无论函数在哪里被调用,也无论它如何被调用,它...

2018-09-18 21:32:16 196

转载 理解JS中的call、apply、bind方法

理解JS中的call、apply、bind方法 在JavaScript中,call、apply和bind是Function对象自带的三个方法,这三个方法的主要作用是改变函数中的this指向。 call、apply、bind方法的共同点和区别: apply 、 call 、bind 三者都是用来改变函数的this对象的指向的; apply 、 call 、bind 三者第一个参数都是this...

2018-06-11 17:15:55 249

原创 Python 笔记 —— 文件

文件夹的遍历# -*- coding:UTF-8 -*-import osimport os.pathrootdir = "C:\Users\Niu\Desktop" # 指明被遍历的文件夹for parent,dirnames,filenames in os.walk(rootdir): #三个参数:分别

2018-02-02 14:42:11 356

转载 Deep Reinforcement Learning 深度增强学习资源

深度增强学习资源

2018-01-21 11:51:07 831

原创 Add Binary

题目Given two binary strings, return their sum (also a binary string).For example, a = "11" b = "1" Return "100".分析对于给定的两个二进制数字所表达的字符串,我们求其相加所得到的结果, 根据上例便可 得到答案. 要注意1. 对字符串的操作.2. 对于加法,我们应该建立一个进位单位,保存

2017-08-18 22:00:01 290

原创 World Break II

题目Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where eachword is a valid dictionary word.Return all such possible sentences.For example, given s = "catsan

2017-08-02 10:32:59 886

原创 Word Break

题目Word BreakGiven a string s and a dictionary of words dict, determine if s can be segmented into a spaceseparatedsequence of one or more dictionary words.For example, given s = "leetcode", dict = ["

2017-08-02 10:25:35 220

原创 证明精确的4SAT是NP-完全问题

题目在精确的4SAT(EXACT 4SAT)问题中,输入为一组字句,每个字句都是恰好4个文字的析取,且每个变量最多在每个字句中出现一次。目标是求它的满足赋值——如果该赋值存在。证明精确的4SAT是NP完全问题。证明由于3SAT问题是NP-完全问题,若能将3SAT问题归约到精确的4SAT问题,则可证明精确的4SAT问题也是NP-完全问题。以下是将3SAT问题归约到精确的4SAT问题:3SAT:I=(a

2017-07-06 11:01:08 958

原创 利用推广的方法证明NP-完全性

对于以下每个问题,请通过证明它是本章某个NP-complete的推广说明它是NP-complete(a)子图同构:给定两个作为输入的无向图G和H,判断G是否与H的某个子图同构,且如果是,返回由V(G)到V(H)的相关映射。 (b)最长路径:给定图G和整数g,求G中一条长为g的简单路径。 (c)最大SAT:给定一个CNF公式和整数g,求满足其中至少g个子句的真赋值。 (d)稠密子图:给定一个图和

2017-07-06 10:37:28 439

原创 吝啬SAT是NP-complete

吝啬SAT的定义给定一组子句(每个子句都是其中文字的析取)和整数k,求一个最多有k个变量为true的满足赋值——如果该赋值存在。显然,解决这个问题最直观最简单的就是使用归约。 这里可由SAT问题归约得来。SAT问题简介:布尔逻辑的可满足性问题(SATISFIABLITY problem),简称为SAT。我们知道,布尔表达式是由布尔变量和运算符(NOT , AND , OR)所构成的表达式。如果对

2017-07-06 10:24:34 523

原创 Best Time to Buy and Sell Stock II

题目Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one a

2017-06-15 21:01:37 225

原创 Assign Cookies

题目Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a co

2017-06-15 20:47:25 286

原创 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 each c

2017-06-14 20:22:11 255

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

2017-06-13 21:00:49 204

原创 Majority Element

题目Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element alway

2017-06-13 20:10:17 234

原创 House Robber

House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adj

2017-06-10 16:55:30 242

原创 Range Sum Query - Immutable

题目Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRange(0, 5)

2017-06-10 16:08:31 268

原创 Integer Break

题目Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n = 2, return

2017-05-31 20:07:46 237

原创 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], [6,5,7],

2017-05-25 19:47:35 226

原创 Evaluate Division

Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answer do

2017-05-02 15:53:48 246

原创 染色

Maximum Subarray做这个题之后,发现自己真的很LOW。。。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 con

2017-04-22 16:10:08 375

原创 Maximum Subarray

Maximum Subarray做这个题之后,发现自己真的很LOW。。。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 con

2017-04-15 20:44:33 346

转载 C++ map的基本操作和用法

1、map简介map是一类关联式容器。它的特点是增加和删除节点对迭代器的影响很小,除了那个操作节点,对其他的节点都没有什么影响。对于迭代器来说,可以修改实值,而不能修改key。2、map的功能自动建立Key - value的对应。key 和 value可以是任意你需要的类型。 根据key值快速查找记录,查找的复杂度基本是Log(N),如果有1000个记录,最多查找10次

2017-04-10 19:59:52 229

原创 图的深度优先遍历

根据老师将解,以及从网络上学习的一点总结使用邻接矩阵#include <iostream> #include <malloc.h> using namespace std;#define VERTEXNUM 5 void createGraph(int (*edge)[VERTEXNUM], int start, int end); void displayGraph(int (*e

2017-04-10 19:29:30 481

原创 图的广度优先遍历

题目读入图的邻接矩阵以及一个顶点的编号(图中顶点的编号为从1开始的连续正整数。顶点在邻接矩阵的行和列上按编号递增的顺序排列。邻接矩阵中元素值为1,表示对应顶点间有一条边,元素值为0,表示对应顶点间没有边),输出从该顶点开始进行广度优先搜索(Breadth-First Search, BFS)的顶点访问序列。假设顶点数目<=100,并且,对于同一顶点的多个邻接顶点,按照顶点编号从小到大的顺序进行搜索这

2017-04-10 19:07:25 390

原创 Integer to Roman

题目Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.解答class Solution {public: string intToRoman(int num) { string ret = "";

2017-03-26 18:12:43 273

原创 Pascal's Triangle

题目Given numRows, generate the first numRows of Pascal’s triangle.For example, given numRows = 5, Return [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]Subscribe to see which companies asked

2017-03-12 15:19:56 216

原创 Different Ways to Add Parentheses

题目Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *.Example 1 Input

2017-03-05 18:24:39 247

原创 初次小试

Try first题目Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Note: The input is assumed to be a 32-bit signed integer. Your functi

2017-02-25 12:51:21 333

原创 CSDN第一天

加油

2017-02-23 18:13:47 227

空空如也

空空如也

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

TA关注的人

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