- 博客(12)
- 收藏
- 关注
原创 leetcode-74 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 each
2017-04-26 10:04:33 180
原创 leetcode-73 set matrix zeros
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 题意是将矩阵中,有0的行列值均置为0. 这道题想要原址,首先需要记录下首行、首列,是否有0。其次从2行2列开始统计,如果有0,则将此位置的首行、首列位置记为0,实现原址。 在改的时候应当注意,首行首列的值
2017-04-25 11:49:03 277
原创 leetcode-71 simplify path
Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/", => "/home" path = "/a/./b/../../c/", => "/c" 路径打印问题,将自己碰到的特殊情况记录如下 1.两个"//"打印为一个"/" 2.出现两个点"/../"
2017-04-17 11:48:17 183
原创 leetcode-68 Text Justification
题目如下: Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You should pack your words in a greedy approach;
2017-04-14 11:40:50 207
原创 leetcode-67 add binary
Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". 题意是将两个二进制串相加 本题与上题类似,都是从后向前相加,维护一个进位。写的比较繁琐 class Solution { public: stri
2017-04-12 11:11:44 246
原创 leetcode-66 plus one
这道题,从后向前依次加和,需要记录下进位,和处理最后的进位 class Solution { public: vector plusOne(vector& digits) { vector res; vector tempres; int jinwei=0; int n = digits.size(); int num = digits[n-1] + 1; i
2017-04-12 10:39:18 177
原创 leetcode-65 valid number
Validate if a given string is numeric. Some examples: "0" => true " 0.1 " => true "abc" => false "1 a" => false "2e10" => true Note: It is intended for the problem statement to be amb
2017-04-11 11:43:22 227
原创 leetcode-59 Spiral Matrix
这是一道旋转矩阵的题,题目如下: Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example, Given n = 3, You should return the following matrix: [ [ 1, 2, 3
2017-04-07 15:22:25 162
原创 leetcode-57 insert interval
有了上道题的基础,这道题将新来的interval插入到原来的intervals当中,然后进行融合即可 Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were i
2017-03-31 10:07:02 170
原创 leetcode-56 merge interval
题目如下 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]. 首先对所有的interval进行排序,这里需要重载sort的比较操作符。 其次对所有的int
2017-03-30 17:05:00 220
原创 leetcode-55 Jump Game
这道题本来准备用递归加回溯的方法做,也就是每次都移动最大,看看能到哪里,如果走不通,再退回一步。这样的做法,通过了72个案例,最后一个案例超时,无法通过。于是思考了贪心的方法,判断每个地方可以到达的最远距离。将两次过程记录下来 第一次, class Solution { public: bool canJump(vector& nums) { if (nums.empty())
2017-03-30 15:17:51 176
转载 caffe提取特征并可视化
1. 配置python 详情见 http://www.cnblogs.com/alfredtofu/p/3577241.html 具体步骤 文件 python/requirements.txt 列举了Caffe依赖的python库,最简单的方法是用pip安装,pip的安装方法: curl -O https://raw.github.com/pypa/pip/mast
2016-08-28 15:58:41 607
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人