自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Ubuntu16.04 + Titan XP + cuda8.0 + cudnn5.1 + opencv3.3.0 + caffe

1、安装Ubuntu16.04制作一个启动盘之后BIOS切换到U盘启动就好辣,跟着提示走。需要注意的是安装系统的时候不能插网线,否则界面会在选择时区那里一直循环。2、NVIDIA显卡驱动如果直接添加源然后sudo apt-get install的话,图形界面会出现一直循环登陆的情况。为了避免这种情况我们采取第二种办法。1、打开终端,先删除旧的驱动:sudo apt-ge

2017-11-29 10:27:58 2718

原创 矩阵中的路径

请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径。路径可以从矩阵中的任意一个格子开始,每一步可以在矩阵中向左,向右,向上,向下移动一个格子。如果一条路径经过了矩阵中的某一个格子,则该路径不能再进入该格子。例如 a b c e s f c s a d e e 矩阵中包含一条字符串"bcced"的路径,但是矩阵中不包含"abcb"路径,因为字符串的第一个字符b占据了矩阵中的第

2017-10-22 20:24:30 378

原创 滑动窗口的最大值

给定一个数组和滑动窗口的大小,找出所有滑动窗口里数值的最大值。例如,如果输入数组{2,3,4,2,6,2,5,1}及滑动窗口的大小3,那么一共存在6个滑动窗口,他们的最大值分别为{4,4,6,6,6,5};针对数组{2,3,4,2,6,2,5,1}的滑动窗口有以下6个: {[2,3,4],2,6,2,5,1},{2,[3,4,2],6,2,5,1}, {2,3,[4,2,6],2,5,1}, {2

2017-10-22 18:07:56 198

原创 数据流中的中位数

如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值,那么中位数就是所有数值排序之后位于中间的数值。如果从数据流中读出偶数个数值,那么中位数就是所有数值排序之后中间两个数的平均值。一刷:完全没思路,看讨论说是用大顶堆和小顶堆。感觉这个题可以扩展一下,自己写一个堆。写的时候问题主要两个,一个是对push的条件判断不清楚,比如num应该 big.top())另一个是在相除的时

2017-10-21 21:41:14 165

原创 二叉搜索树的第K个节点

给定一颗二叉搜索树,请找出其中的第k大的结点。例如, 5 / \ 3 7 /\ /\ 24 6 8 中,按结点数值大小顺序第三个结点的值为4。一刷:两种方法,递归和非递归用中序遍历。问题主要出在写中序遍历的时候,一个是没有加判断条件k>0, 一个是没有考虑到k比实际取数组的值大1.class Solution {public: int count = 0; T

2017-10-21 21:14:08 133

原创 581. Shortest Unsorted Continuous Subarray

Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too.You need to fin

2017-06-12 19:35:03 187

原创 565. Array Nesting

A zero-indexed array A consisting of N different integers is given. The array contains all integers in the range [0, N - 1].Sets S[K] for 0 S[K] = { A[K], A[A[K]], A[A[A[K]]], ... }.Sets S

2017-06-12 19:29:18 161

原创 532. K-diff Pairs in an Array

Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers

2017-06-12 19:23:57 155

原创 41. First Missing Positive

Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant

2017-06-12 19:18:51 148

原创 287. Find the Duplicate Number

Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number,

2017-06-02 09:54:03 173

原创 279. Perfect Squares

Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n =

2017-06-02 09:44:25 190

原创 57. Insert Interval & 56. 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].先按start排好序,之后遍历,如果上一个的end大于下一个的start的时候,证明有重叠,修改结果数组

2017-05-28 20:55:59 184

原创 274. H-Index & 275. H-Index II

Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to the definition of h-index on Wikipedia: "A

2017-05-28 19:55:03 229

原创 260. Single Number III

Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:Given nums =

2017-05-12 10:16:25 151

原创 263. Ugly Number && 264. Ugly Number II

Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example,6, 8 are ugly while 14 is not ugly since i

2017-05-10 22:06:32 155

原创 416. Partition Equal Subset Sum

Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.Note:Each of the array e

2017-05-04 21:12:26 143

原创 516. Longest Palindromic Subsequence

Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.Example 1:Input:"bbbab"Output:4One possible longest

2017-05-04 20:50:36 150

原创 338. Counting Bits

Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num = 5 y

2017-05-04 20:43:07 147

原创 DP一周总结

70. Climbing Stairs 96. Unique Binary Search Trees 338. Counting Bits 416. Partition Equal Subset Sum 516. Longest Palindromic Subsequence 523. Continuous Subarray Sum 感觉DP的主要思路就是首先要把问题抽象化

2017-05-04 20:33:37 181

原创 BFS一周总结

130. Surrounded Regions 542. 01 Matrix515. Find Largest Value in Each Tree Row513. Find Bottom Left Tree Value 101. Symmetric Tree107. Binary Tree Level Order Traversal II 前两道是矩阵遍历,后四道是树的遍

2017-04-17 12:11:22 179

原创 234. Palindrome Linked List

Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?/** * Definition for singly-linked list. * struct ListNode { * int val;

2017-04-08 18:58:44 152

原创 238. Product of Array Except Self

Given an array of n integers where n > 1, nums, return an arrayoutput such that output[i] is equal to the product of all the elements ofnums except nums[i].Solve it without division and in O(n).

2017-04-08 18:55:25 146

原创 232. Implement Queue using Stacks && 225. Implement Stack using Queues

implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front element.empty(

2017-04-05 18:41:20 141

原创 230. Kth Smallest Element in a BST && 530. Minimum Absolute Difference in BST

530Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes.Example:Input: 1 \ 3 / 2Output:1Explanat

2017-03-28 16:52:15 153

原创 401. Binary Watch

A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent theminutes (0-59).Each LED represents a zero or one, with the least significant bit on

2017-03-21 12:01:00 197

原创 166. Fraction to Recurring Decimal

Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating, enclose the repeating part in parentheses.

2017-03-12 21:18:55 179

原创 222. Count Complete Tree Nodes

Given a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completely filled,

2017-03-12 10:53:45 156

原创 221. Maximal Square

Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0

2017-03-12 10:45:32 194

原创 218. The Skyline Problem

class Solution {public: vector> getSkyline(vector>& buildings) { vector> height, skyline; for(auto b : buildings){ height.push_back(make_pair(b[0], -b[2]));

2017-03-12 10:37:57 225

原创 208. Implement Trie (Prefix Tree)

Implement a trie with insert, search, and startsWith methods.trie是一棵树,用于存储字符串的,有公共前缀的字符串在一棵子树上。class TrieNode{ public: TrieNode* next[26]; bool is_word; TrieNode(bool b=fals

2017-03-07 21:17:34 255

原创 207. Course Schedule

There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a

2017-03-07 20:19:04 153

原创 515. Find Largest Value in Each Tree Row

You need to find the largest value in each row of a binary tree.Example:Input:           1         / \        3   2       / \   \        5   3   9 Output: [1, 3, 9]BFS+维护一个每行

2017-03-03 10:49:31 164

原创 513. Find Bottom Left Tree Value

Given a binary tree, find the leftmost value in the last row of the tree.Example 1:Input:    2   / \  1   3Output:1Example 2:Input:        1       / \      2   3

2017-03-03 10:46:20 163

原创 450. Delete Node in a BST

Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.Basically, the deletion can be divided int

2017-03-03 10:44:40 164

原创 数据结构——树 总结篇

以后把遇到的树的问题都总结在这一篇里啦~1.普通的树的数据结构表示struct TreeNode{TYPE element;//该节点的元素TreeNode *firstChild;//指向该节点的第一个孩子TreeNode *nextSibling;//指向该节点的兄弟节点};http://blog.csdn.net/linux_ever/article/detail

2017-03-03 10:26:35 264

原创 215. 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.

2017-02-28 17:41:08 136

原创 451. Sort Characters By Frequency&&347. Top K Frequent Elements

451.Given a string, sort it in decreasing order based on the frequency of characters.Example 1:Input:"tree"Output:"eert"Explanation:'e' appears twice while 'r' and 't' both a

2017-02-28 17:18:20 195

原创 201. Bitwise AND of Numbers Range

Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4.这题有点神……我一直以为1&1应该是1的……竟然是0……对于整数m到n,在数值连续变化的过程中,它们的某些高位比特是相同的,而只有低位的比特连续变化。例如:整数:33,34,35,36

2017-02-27 17:32:55 132

原创 205. Isomorphic Strings

Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with anot

2017-02-27 17:21:23 165

原创 200. Number of Islands

Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume

2017-02-27 17:18:38 148

空空如也

空空如也

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

TA关注的人

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