- 博客(31)
- 资源 (2)
- 收藏
- 关注
原创 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 always...
2018-05-29 18:42:40
184
原创 167. Two Sum II - Input array is sorted
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers su...
2018-05-29 18:41:02
200
原创 717. 1-bit and 2-bit Characters
We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11). Now given a string represented by several bits. Re...
2018-05-29 18:38:07
214
原创 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-05-28 16:05:51
184
原创 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-05-28 14:07:50
193
原创 561. Array Partition I
Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as poss...
2018-05-28 13:44:53
146
原创 832. Flipping an Image
Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image.To flip an image horizontally means that each row of the image is reversed. For example...
2018-05-28 11:36:45
181
原创 387. First Unique Character in a String
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examples:s = "leetcode"return 0.s = "loveleetcode",return 2.Note: You may assume...
2018-05-24 14:07:39
190
原创 7. Reverse Integer
Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume we are dealing with an envir...
2018-05-23 16:22:36
213
原创 344. Reverse String
Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".func reverseString(s string) string { rs := []rune(s) for i, j := 0, len...
2018-05-23 15:24:46
186
原创 1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same el...
2018-05-23 12:01:56
162
原创 283. Move Zeroes
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.Example:Note:You must do this in-place without making a copy of the...
2018-05-23 00:07:30
166
原创 66. Plus One
Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each element i...
2018-05-22 17:21:53
199
原创 350. Intersection of Two Arrays II
Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note:Each element in the result should appear as many times as it sho...
2018-05-22 15:00:06
187
原创 136. Single Number
Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using ...
2018-05-22 12:25:00
149
原创 217. Contains Duplicate
Given an array of integers, find if the array contains any duplicates.Your function should return true if any value appears at least twice in the array, and it should return false if every element is ...
2018-05-22 10:16:26
158
原创 189. Rotate Array
Given an array, rotate the array to the right by k steps, where k is non-negative.Example 1:Input: [1,2,3,4,5,6,7] and k = 3Output: [5,6,7,1,2,3,4]Explanation:rotate 1 steps to the right: [7,1,2,3,...
2018-05-21 17:14:49
177
原创 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 (i.e., buy one ...
2018-05-21 16:59:39
220
原创 26. Remove Duplicates from Sorted Array
Given a sorted array nums, 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 by modifying...
2018-05-21 16:41:13
202
原创 C++Primer 第三章 字符串,向量和数组
知识点:1.如果使用等号初始化一个变量,为拷贝初始化(copy initialization),否则为直接初始化(direct initialization)2.string 对字母大小写敏感。3.读取位置数量的string对象:int main { string word; while(cin>>word) cout<<word<<e...
2018-05-07 09:45:26
242
原创 C++Primer 第二章 变量和基本类型
知识点:1.切勿混用带符号类型和无符号类型。2. C++中初始化不是赋值,初始化的含义是创建变量时赋予其一个初始值,而赋值的含义是把对象的当前值擦除,而以一个新值来替代。3.列表初始化(list initialization):C++11中,用花括号初始化变量,当初始值存在丢失信息风险时,编译器将报错。4.默认初始化(default initialization):一些类要求每个对象都显式初始化,...
2018-05-02 14:24:37
211
原创 C++Primer 第一章 开始
知识点:1. main函数的返回类型必须为int。2. 一个注释不能嵌套早另一个注释之内。3. 成员函数(member function)是定义为类的一部分的函数,有时也被称为方法(method)4. 写入操作符(manipulator),结束当前行,并将与设备关联的缓冲区中的内容刷到设备中。缓冲刷新操作可以保证到目前为止程序所产生的所有输出都真正写入输出流中,而不是仅停留再内存中等待写入流。5...
2018-05-02 10:47:48
243
原创 771.Jewels and Stones
You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the sto...
2018-04-11 10:00:30
143
原创 RailsGuide学习要点整理
关于Rails Rails 是使用 Ruby 语言编写的 Web 应用开发框架,目的是通过解决快速开发中的共通问题,简化 Web 应用的开发。与其他编程语言和框架相比,使用 Rails 只需编写更少代码就能实现更多功能。Rails 哲学两大指导思想: ·不要自我重复(DRY): DRY 是软件开发中的一个原则,意思是“系统中的每个功能都要具有单一、准确、可信的实现。”。不重复表述同一件事,写出的代...
2018-03-02 23:48:05
447
转载 MAC OS 快捷键
剪切、拷贝、粘贴和其他常用快捷键Command-X 剪切所选项并将其拷贝到剪贴板。 Command-C 将所选项拷贝到剪贴板。这同样适用于 Finder 中的文件。 Command-V 将剪贴板的内容粘贴到当前文稿或应用中。这同样适用于 Finder 中的文件。 Command-Z 撤销前一个命令。随后您可以按 Command-Shift-Z 来重做,从而反向执行撤销命令。在某些应用中,您可以撤销...
2018-03-01 18:38:29
205
转载 MAC terminal 快捷键
SHORTCUTSKey/CommandDescriptionCtrl + AGo to the beginning of the line you are currently typing on. This also works for most text input fields system wide. Netbeans being one exceptionCtrl + EGo to th...
2018-03-01 18:36:48
705
转载 Safari快捷键
上下方向键 小范围的垂直滚动页面 左右方向键 小范围的水平滚动页面 Option + 方向键 整屏的滚动页面 Cmd + 上下方向键 滚动到页面的最上或最 空格键 整屏滚动 Del 后退 Shift + Del 向前 Page up Page down 整屏滚动 Home 与 End 同 Cmd + 上下方向键 Cmd-Home 转到首页 Esc 如果正在输入地址栏,则返回当前地址 Cmd-点击 ...
2018-03-01 18:24:18
496
Redis从入门到高可用,分布式实践 (完整13章版本)
2018-06-22
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人