自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(30)
  • 资源 (2)
  • 收藏
  • 关注

原创 [LeetCode] Maximal Square(!!!!DP优化)

定义一个D[i][j] 表示的是以i,j为右下角的最大子正方形的边长。这个边长是受限于D[i-1][j],D[i][j-1] ,D[i-1][j-1]中最小的那个的。class Solution {public: int maximalSquare(vector<vector<char>>& A) { int m = A.size(); if(m==0) retu

2015-08-27 20:13:28 346

原创 [LeetCode] Maximal Rectangle(!!!DP)

关于最大某某问题,使用DP思想来求解,在最大子问题系列中有较为详细的解答。 Maximal Rectangle Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing all ones and return its area. (实在不能理解为什么要用char)c

2015-08-27 16:08:06 561

原创 [LeetCode] Set Matrix Zeroes (!!!!时间空间复杂度)

Set Matrix Zeroes Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up: Did you use extra space? A straight forward solution

2015-08-27 14:40:47 356

原创 [LeetCode] Edit Distance(!!!!!DP)

Edit Distance Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 opera

2015-08-27 11:13:30 319

原创 [LeetCode] Merge Sorted Array

Merge Sorted Array Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 has enough space (size that is greater o

2015-08-25 11:00:36 299

原创 [LeetCode] Partition List(!!!!巧妙的链表插入)

Partition List Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order

2015-08-24 21:39:29 254

原创 [LeetCode] Remove Duplicates from Sorted Array II

Remove Duplicates from Sorted Array II Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice? For example, Given sorted array nums = [1,1,1,2,2,3], Your fun

2015-08-24 19:43:59 271

原创 [LeetCode] World Search(!!!!回溯&&char *代替string&&递归)

Word Search Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizon

2015-08-24 15:50:27 347

原创 [LeetCode] Subsets(!!!!!回溯&&迭代&&位操作)(to be updated)

Subsets Given a set of distinct integers, nums, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets.

2015-08-23 22:58:07 564

原创 [LeetCode] Combinations

Combinations Given two integers n and k, return all possible combinations of k numbers out of 1 … n. For example, If n = 4 and k = 2, a solution is: [ [2,4], [3,4], [2,3], [1,2]

2015-08-23 22:27:40 258

原创 [LeetCode] Sort Colors(!!两个指针)

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,

2015-08-23 21:12:50 363

原创 [LeetCode] Search a 2D Matrix(二分查找)

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 from left to right. The first integer of

2015-08-23 20:38:32 263

原创 数组及多维数组

c++中没有多维数组的概念,多维数组就是数组的数组。按照从内向外的阅读顺序有助于更好地理解其真实含义。在c++11中增加了范围for的使用二重for来处理二维数组size_t cnt=0;int ia[r][c];for(size_t i=0; i!=r; ++i) for(size_t j=0; j!=c; ++j){ ia[i][j]=cnt; ++c

2015-08-23 17:31:11 380

原创 [LeetCode]Climbing Stairs

Climbing Stairs You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?基础的DP,到达

2015-08-23 00:49:14 270

原创 [LeetCode]Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with cons

2015-08-23 00:47:06 254

原创 [LeetCode] Sqrt(x)

Sqrt(x) Implement int sqrt(int x). Compute and return the square root of x.题目的意思是找x的平方根,思路也是比较简单 是使用二分法查找关键在比较时有个问题不能使用mid*mid与x比较 而是应该使用mid与x/midclass Solution {public: int mySqrt(int x

2015-08-22 22:27:05 311

原创 [LeetCode] Add Binary

Add Binary Given two binary strings, return their sum (also a binary string). For example, a = “11” b = “1” Return “100”. 题目的意思也是比较简单,两个二进制数组相加,如果两个数组都已经加完还有进位的话,则要在最前面加’1’class Solutio

2015-08-22 20:24:19 364

原创 [LeetCode] Plus One

Plus One Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list.题目是的意思是

2015-08-22 14:58:04 284

原创 [LeetCode]Minimum Path Sum

Minimum Path Sum Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.思路还是最基本的DP,class Solution {

2015-08-21 23:02:45 264

原创 [LeetCode] Unique Paths II

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 a

2015-08-21 22:47:02 300

原创 各种排序算法实现及总结

本文主要比较一下各种排序的性能(平均时间复杂度和最差情况)和基本实现。 这个默认按照从小到大排列,输入的数据可以重复,假设输入的数组为A,下标从0到N-1注意在比较算法复杂度时,我们会关注键值的比较次数和交换次数。1、冒泡排序 冒泡排序如果不是因为名字比较好记,没有任何优势。它的思路是一趟又一趟的比较数组(或者链表也可以)中相邻的两个元素,如果前一个比后一个大,则交换。这样,每一轮之后,最大的那

2015-08-21 21:20:18 636

原创 Linux系统负载

阿里2014校招笔试的一道题目 22.关于Linux系统的负载,以下表述正确的是: A: 通过就绪和运行的进程数来反映 B: 通过TOP命令查看 C: 通过uptime查看 D: Load:2.5,1.3,1.1表示系统的负载压力在逐渐变小 参考答案:BC再学习下Linux系统负载的知识查看的命令 w or uptime or procinf

2015-08-21 19:38:32 2435

原创 C语言 字节对齐

字节对齐的目的是使CPU能对变量进行快速访问。 字节对齐,对于标准数据类型,它的地址只要是它的长度的整数倍就可以了。对于非标准数据类型按照下面的原则对齐数组 :按照基本数据类型对齐,第一个对齐了后面的自然也就对齐了。 联合 :按其包含的长度最大的数据类型对齐。 结构体: 结构体中每个数据类型都要对齐。举例说明例1struct test { char x1; short x2; fl

2015-08-21 17:10:59 414

原创 [LeetCode] 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 rea

2015-08-21 14:34:53 271

原创 [LeetCode] Rotate List

Rotate List Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL.题目的意思先梳理下,如果list的长

2015-08-21 12:31:05 287

原创 [LeetCode] Permutation Sequence

Permutation Sequence Total 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

2015-08-20 22:09:22 311

原创 [LeetCode] Insert Interval

Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start time

2015-08-19 16:11:43 333

原创 [LeetCode]Merge Intervals

Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]./** * Definition for an interval. * struct Interv

2015-08-18 23:05:41 417

原创 可调用对象

c++中常常可以重载算法(for_each等)或智能指针中一些函数可以用可调用对象重载。先以unique_ptr来说明 unique_ptr是智能指针的一种,可以独占所指向的对象。 unique_ptr使用直接初始化新式。unique_ptrint> p2(new int(42)); //p2指向一个值为42的int因为unique_ptr独占所指向的对象,因此uniqu

2015-08-18 21:13:11 456

原创 最大子段和||最大子矩阵和||最大全1子矩阵||最大全1子正方形||

最大子段和 给定n个整数组成的序列A[0,1,…,n-1],求该序列子段的最大和。算法一枚举所有可能的左右边界l,r,计算sum[l,...r],算法复杂度为O(n^3)算法二sum[l,...r]的值可以由sum[0,...r]-sum[0,...l]得到。在O(n)内我们可以得到sum[0,..,n],这样只有r,l可以变化,算法复杂度为O(n^2),这是典型的空间换时间。算法三(DP)我

2015-08-18 19:15:55 3286

C 大型程序欣赏

c语言的大型程序 建议已经学过C 语言的人看 刚学的不适合

2010-10-11

c语言上机操作指导(tc和bc)

详细讲解TC和BC在windows下的上机操作

2010-03-26

空空如也

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

TA关注的人

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