- 博客(19)
- 收藏
- 关注
原创 NN
学习kNN k-近邻算法(kNN):存在一个样本集合,也称作训练样本集,并且样本集每个数据都存在标签,即我们知道样本集中每一数据与所属分类的对应关系。输入没有标签的新数据后,将新数据的每个特征与样本集中数据对应的特征进行比较,然后算法提取样本集中特征最相似数据(最近邻)的分类标签。一般来说,我们只选择样本数据集中前k个最相似的数据,最后选择k个最相似数据集中出现次数最多的分类,作为新数据的分类。 ...
2018-10-26 10:27:45
617
原创 7. Reverse Integer
7. Reverse Integer 题目: Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume ...
2018-10-19 10:26:43
118
原创 5. Longest Palindromic Substring
5. Longest Palindromic Substring 题目: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: “babad” Output: “bab” Note: “...
2018-10-15 21:33:16
118
原创 6. ZigZag Conversion
6. ZigZag Conversion 题目: The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P ...
2018-10-06 22:08:08
113
原创 3. Longest Substring Without Repeating Characters
3. Longest Substring Without Repeating Characters 题目: Given a string, find the length of the longest substring without repeating characters. Example 1: Input: “abcabcbb” Output: 3 Explanation: The ans...
2018-10-05 20:08:12
127
原创 2. Add Two Numbers
2. Add Two Numbers 题目: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the t...
2018-10-05 10:03:06
113
原创 C++问题汇总
memset 对于memset的使用,使用memset初始化小块内存时,比for和while循环要快一些而且代码相对简洁。 但是之前写成memset(hashTable,0,256),容易出错,因为后面的表大小的参数(例如256)是以字节为单位,所以,对于int或其他的就并不是都乘默认的1(字符型)了。而且不同的机器上int的大小也可能不同,所以最好用sizeof()。写成memset(hashT...
2018-09-29 11:02:57
151
原创 771. Jewels and Stones
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 ...
2018-09-29 10:54:52
98
原创 485. Max Consecutive Ones
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: 3 Explanation: The first two digits or the last thr...
2018-09-29 10:14:36
129
原创 888. Fair Candy Swap
888. Fair Candy Swap Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, and B[j] is the size of the j-th bar of candy that Bob has. Since they ...
2018-09-28 17:19:28
160
原创 896. Monotonic Array
896. Monotonic Array 题目: An array is monotonic if it is either monotone increasing or monotone decreasing. An array A is monotone increasing if for all i <= j, A[i] <= A[j]. An array A is monot...
2018-09-28 10:30:45
157
原创 566. Reshape the Matrix
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 matr...
2018-09-28 09:57:57
109
原创 442. Find All Duplicates in an Array
442. Find All Duplicates in an Array 题目: Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements that appear twice in thi...
2018-09-27 21:34:07
108
原创 766. Toeplitz Matrix
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. Exampl...
2018-09-27 10:50:37
102
原创 867. Transpose Matrix
867. Transpose Matrix 题目: Given a matrix A, return the transpose of A. The transpose of a matrix is the matrix flipped over it’s main diagonal, switching the row and column indices of the matrix. Exam...
2018-09-27 09:51:56
243
原创 832. Flipping an Image
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 ima...
2018-09-26 10:50:21
107
原创 905. Sort Array By Parity
905. Sort Array By Parity 题目: Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A. You may return any answer arra...
2018-09-26 09:54:16
128
原创 561. Array Partition I
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 fro...
2018-09-26 09:26:42
95
原创 1.Two Sum
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 ...
2018-09-25 21:47:43
107
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅