- 博客(14)
- 资源 (9)
- 收藏
- 关注
原创 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 surrou...
2018-04-28 20:08:42 97
原创 485. Max Consecutive Ones
Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are consecutive 1s. ...
2018-04-26 21:38:58 108
原创 566. Reshape the Matrix
In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data.You're given a matrix represented by a two-dimensi...
2018-04-26 10:51:09 84
原创 766. Toeplitz Matrix
A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element.Now given an M x N matrix, return True if and only if the matrix is Toeplitz. Example 1:Input: matrix = [[1,2,...
2018-04-25 21:48:54 91
原创 520. Detect Capital
Given a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of the following cases holds:All letters in this word...
2018-04-12 22:29:40 106
原创 500. Keyboard Row
Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below.Example 1:Input: ["Hello", "Alaska", "Dad", "Peace"]Out...
2018-04-10 21:18:04 118
原创 557. Reverse Words in a String III
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: "Let's take LeetCode contest"Outpu...
2018-04-09 11:37:19 100
原创 811. Subdomain Visit Count
A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the lowest level, "discuss.leetcode.com"...
2018-04-09 11:04:59 310
转载 auto 指定符
1) 在块作用域、命名空间作用域、循环初始化语句等中声明变量时,关键词 auto 可用作类型指定符。只要初始化器的类型被确定,则编译器会用来自函数调用的模板实参推导规则所决定的类型替换关键词 auto (细节见模板实参推导)。关键词 auto 可与修饰符组合,如 const 或 & ,它们将参与类型推导。例如,给出 const auto& i = expr; , i 的类型恰是虚构...
2018-04-09 10:53:10 144
转载 unordered_map的用法
在c++11以前要使用unordered_map需要 #include<tr1/unordered_map>//在unordered_map之前加上tr1库名, using namespace std::tr1;//与此同时需要加上命名空间[查找元素是否存在] 若有unordered_map<int, int> mp;查找x是否在map中 方法1...
2018-04-09 10:19:46 266
原创 806. Number of Lines To Write String
We are to write the letters of a given string S, from left to right into lines. Each line has maximum width 100 units, and if writing a letter would cause the width of the line to exceed 100 units, it...
2018-04-04 09:54:02 170
原创 804. Unique Morse Code Words
International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a"maps to ".-", "b" maps to "-...", "c" maps to "-.-.", and so on.For
2018-04-03 17:07:48 134
转载 【C++11新特性】 auto关键字
熟悉脚本语言的人都知道,很多脚本语言都引入了“类型自动推断”技术:比如python,可以直接声明变量,在运行时进行类型检查。随着C++11标准的发布,C++语言也引入了类型自动推断的功能,这就是我们今天要介绍的auto关键字。C++是一种强类型语言,声明变量时必须明确指出其类型。但是,在实践中,优势我们很难推断出某个表达式的值的类型,尤其是随着模板类型的出现,要想弄明白某些复杂表达式的返回类型就变...
2018-04-03 16:31:11 88
转载 C++中set用法详解
1.关于setC++ STL 之所以得到广泛的赞誉,也被很多人使用,不只是提供了像vector, string, list等方便的容器,更重要的是STL封装了许多复杂的数据结构算法和大量常用数据结构操作。vector封装数组,list封装了链表,map和set封装了二叉树等,在封装这些数据结构的时候,STL按照程序员的使用习惯,以成员函数方式提供的常用操作,如:插入、排序、删除、查找等。让用户在S...
2018-04-03 10:23:23 213
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人