自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 个人理解——为什么要学习算法

在程序设计题的时候经常会遇到一下问题:根本没有解决问题的思路有思路但是设计不出算法设计出了算法但是算法复杂度太高了针对以上问题,希望通过学习算法达到以下目的:设计高效且正确的算法正确的实现并且,为了设计算法,同时锻炼灵活的想象力算法的基础知识...

2018-02-08 13:32:58 1508

原创 CSS中几种控制页面布局的定位机制(相对定位与绝对定位)

CSS中几种控制页面布局的定位机制对于web的初学者来说,CSS中的几种定位方式经常让人摸不着头脑,从而达不到想要的页面布局效果,我去年学习web编程的时候就对这个一知半解,今天,回过头来再次学习web编程,趁有时间就好好总结一下CSS中的几种定位方式,也当自己再学习巩固一下。CSS中包含三种控制页面布局的定位机制:普通流、相对定位、绝对定位。在CSS中通过position属性表明定位机制。此外还可

2017-07-13 22:17:23 10582 2

转载 Intent详解

自助者天助—Intent详解一篇关于intent非常详细的博客,因为不能直接从博客园转载博客到csdn,就只好采用这种方式,上面是博客链接。

2018-03-07 21:51:37 265

原创 Activity生命周期详解

关于Activity在Android应用程序里,一个Activity就是一个用户界面。用户与程序的交互就是通过Activity来实现的,可以看成网站的页面。主Activity是程序启动的入口。应用程序成功启动之后,呈献给用户的第一个界面,即为该程序的主Activity。Activity的四种状态Android 的虚拟机(VM)是使用基于栈(Stack based) 管理,主要有四种...

2018-03-07 00:00:16 592

原创 牛客网剑指offer—顺时针打印矩阵

描述:输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印出数字1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10.思路:感觉这道题是第一页20道题里面最难的了,我也想不到什么好的办法,只有老老实实地用几个循环进行处理。 我们通过分...

2018-02-22 13:09:09 369

原创 牛客网剑指offer—合并两个排序的链表

描述:输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则。思路1:使用递归,递归的思路非常简单,先比较当前两个链表“首结点”的值,把有较小值的节点插入到新的链表,然后将除去这个结点的剩余链表和另一个链表进行递归,具体的代码如下:class Solution {public: ListNode* Merge(ListNode* p...

2018-02-21 21:48:01 322

原创 通过一个c++程序来理解两个指针的赋值

c++程序如下:#include <iostream>using namespace std;struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { }};int main() { L...

2018-02-21 16:44:33 10513 5

原创 牛客网剑指offer—反转链表

描述:输入一个链表,反转链表后,输出链表的所有元素。思路1:用一个栈将链表的所有结点先保存下来,然后在赋给新的链表。 最开始就是使用的这种方法,利用了栈的特性,就是空间复杂度比较高。class Solution {public: ListNode* ReverseList(ListNode* pHead) { if(pHead == NULL |...

2018-02-21 16:26:17 669

原创 牛客网剑指offer—链表中倒数第k个结点

描述:输入一个链表,输出该链表中倒数第k个结点。思路1:我么都知道链表是不计数的,没有处理的情况下是不知道链表的结点个数的。因此最开始拿到这道题的想法就是想去计算得到链表的结点个数,知道结点个数后要求就很好达到了,这种想法下可以有以下代码:class Solution {public: ListNode* FindKthToTail(ListNode* pListHe...

2018-02-21 12:53:14 253

原创 牛客网剑指offer—调整数组顺序使奇数位于偶数前面

描述:输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变。思路:这道题我能想到的方法时间复杂度最小为O(n),想了一下,应该也没有其他时间复杂度更小的方法了,具体有两种思路:思路1:再开一个vector容器,遍历两次,第一次保存奇数列,第二次保存偶数列...

2018-02-21 11:47:02 704

原创 使用非递归的方式实现斐波那契数列

斐波那契数列一般是大家学习递归的入门课,斐波那契数列可以帮助大家很容易的理解递归,但是使用递归的方法有一个缺点,就是对于一个确定的n,他的值往往会被计算很多次,因此当你对算法的时间复杂度要求比较高的时候,递归的方法就不能胜任,这个时候可以采用迭代的方法来实现斐波那契数列,具体的代码如下,很容易理解:实现1:class Solution {public: int Fibonacci...

2018-02-21 01:27:30 2611

原创 牛客网剑指offer—旋转数组的最小数字

描述:把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。思路:这道题的大概思路主要有以下几种: 1,最普通的方法,直接按照普通数组的处理,获取数组的最小值...

2018-02-21 01:04:56 336

原创 TeXstudio 安装中的一些问题

问题如果安装好TeXstudio运行出现以下报错的话,就很有可能和我遇到了同样的问题,下面是这个问题的一个可能的解决方法,希望能够帮助到你。Make sure that you have installed a (La)TeX distribution e.g. MiKTeX or TeX Live, and have set the correct paths to this distr...

2018-02-02 17:50:43 21857 1

原创 字符串的移位包含问题

题目描述:给定两个字符串s1和s2,要求判断s2是否能够被s1做循环移位(rotate)得到字符串的包含。例如 s1 = AABCD和s2 = CDAA,返回true;给定s1 = ABCD 和 s2 = ACBD,返回false。循环移位: 即对于一个长度为N的字符串数组,把下标为0的字符放到下标为1的字符的位置,把下标为1的字符放到下标为2的字符的位置,……把下标为N-2的字符放到下标

2018-01-24 22:42:14 1356

原创 [LeetCode] Algorithms-45. 230. Kth Smallest Element in a BST

描述:Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.Follow up: What if the

2018-01-13 20:02:03 231

原创 [LeetCode] Algorithms-45. 123. Best Time to Buy and Sell Stock III

描述: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 at most two transactions.Note: You may

2018-01-13 19:16:13 177

原创 [LeetCode] Algorithms-122. 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

2018-01-12 00:05:47 172

原创 [LeetCode] Algorithms-121. Best Time to Buy and Sell Stock

描述:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stoc

2018-01-11 23:46:03 134

原创 [LeetCode] Algorithms-63. Unique Paths II

描述:Follow up for “Unique Paths”:Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the g

2018-01-11 18:01:10 193

原创 [LeetCode] Algorithms-62. 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 t

2018-01-11 14:18:21 209

原创 [LeetCode] Algorithms-45. Jump Game II

描述Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal i

2018-01-11 12:55:57 177

原创 [LeetCode] Algorithms-55. Jump Game

描述:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine

2018-01-11 02:26:00 176

原创 算法设计与分析期中练习题整理 2017

1000. 分组Description对于一个整数数列A[0], A[1], …, A[N-1]进行分组,要求每组1到2个数,并且同组之和不能大于w. 求最少可以分成多少组.1 例1:当A = {2, 5, 4, 3}, w = 5, minPartition(A, w)返回3. 将2和3放一组,4和5各自单独作为一组,共3组.例2:当A = {2, 5, 4, 3}, w

2018-01-06 01:17:19 2057

原创 算法概论(注释版)习题8.3

题目:吝啬SAT问题是这样的:给定一组子句(每个子句都是其中文字的析取)和整数k,求一个最多有k个变量为true的满足赋值——如果该赋值存在。证明吝啬SAT是NP-完全问题。补充:什么是SAT问题? SAT问题也称为合取范式的可满足问题,一个合取范式形如: A1∧A2∧…∧An A1∧A2∧…∧An 其中子句 Ai(1≤i≤n)Ai(1≤i≤n)形如:a1∨a2∨…∨aka1

2018-01-05 22:38:26 388

原创 [LeetCode] Algorithms-714. Best Time to Buy and Sell Stock with Transaction Fee

描述:Your are given an array of integers prices, for which the i-th element is the price of a given stock on day i; and a non-negative integer fee representing a transaction fee. You may complete as man

2017-11-12 14:25:38 154

原创 [LeetCode] Algorithms-513. Find Bottom Left Tree Value

[LeetCode] Algorithms-513. Find Bottom Left Tree Value

2017-11-01 14:31:26 171

原创 [LeetCode] Algorithms-515. Find Largest Value in Each Tree Row

描述You need to find the largest value in each row of a binary tree.Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9]思路使用宽度优先搜索的方式递归遍历树,遍历过程中将结果向量大小与当前深度比较,

2017-11-01 14:11:55 136

原创 [LeetCode] Algorithms-257. Binary Tree Paths

描述思路代码/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */

2017-10-15 00:29:32 215

原创 [LeetCode] Algorithms-547. Friend Circles

[LeetCode] 547. Friend Circles

2017-10-14 00:28:30 295

原创 [LeetCode] Algorithms-695. Max Area of Island

描述Given a non-empty 2D array grid of 0’s and 1’s, an island is a group of 1’s (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surro

2017-10-10 12:17:11 368

原创 [LeetCode] Algorithms-53. 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] has t

2017-09-23 20:39:27 171

原创 [LeetCode] Algorithms-169. 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-09-22 17:07:48 177

原创 [LeetCode] Algorithms-2. 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 return

2017-09-22 15:47:09 177

原创 [LeetCode] Algorithms-3.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”, which the length is 3. Given “bbbbb”, the answer is “b”,

2017-09-22 13:12:53 205

原创 [LeetCode] Algorithms-9. Palindrome Number

描述Determine whether an integer is a palindrome. Do this without extra space. 简单地说就是在不使用额外内存空间的情况下判断一个数是否是 回文数思路其实这道题我还是有一些疑惑的,不使用额外的内存空间,那如果我声明两个额外的变量,算不算使用了额外的内存空间呢,比如在下面的代码中,声明了两个变量a,b,但是提交的时候是可以的通过

2017-09-18 13:00:37 384

原创 c++类的构造函数类型介绍及其特点

本人小白,最近刚开始学c++,正在在学习类,这里根据自己所学的,总结一下在类中很重要的一类成员函数-构造函数,有什么不对的地方或者说的不准确的地方欢迎各位指出类的分类大概可以分为三类,即默认构造函数,一般构造函数,以及拷贝构造函数ps:还有一种构造函数叫做无参构造函数,个人觉得默认构造函数与无参构造函数可以归为同一类1.默认构造函数 (无参构造函数)如果创建一个类你没有写任何构造函数,则系统会自动生

2016-04-10 21:33:34 6706 1

原创 常量指针与指针常量的一些个人理解

1.常量指针:(const type *p 或者 type const *p)主语是指针,指针指向的对象是常量,即*p是常量,p地址指向的值不可以直接修改,但由于常量指针本身是一个指针变量,因此可以修改指针指向的地址例:int a = 8; b =9; int *p = &a;有以下语句:p = &b;(用法正确, p是一个变量,为指向的地址,可以修改)...

2016-04-10 20:23:33 336

原创 C语言错误:expected declaration or statement at end of input 归纳总结

可能错误:1. 某一个函数或者变量没有在使用之前声明。2. 某个地方少了个括号。(并不一定是编译器指出错误的地方,这种情况,编译器一般会在最后一行代码报错,但错误很可能不在最后一行,要靠自己去找出来)

2016-03-12 22:42:09 129524 20

空空如也

空空如也

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

TA关注的人

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