LeetCode刷题笔记
本专栏为记录刷LeetCode中遇到的一些最开始做起来没那么顺利的题目,以供今后复习反思
RJzz
正在学习中
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode刷题笔记:缺失数字
Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array. Example 1: Input: [3,0,1] Output: 2 Example 2: Input: [9,6,4,2,3,5,7,0,1] ...原创 2018-09-04 20:41:46 · 429 阅读 · 1 评论 -
LeetCode刷题笔记:帕斯卡三角形
Given a non-negative integer numRows, generate the first numRows of Pascal’s triangle. Given a non-negative integer numRows, generate the first numRows of Pascal’s triangle. Example: Input: 5 O...原创 2018-09-04 16:22:49 · 455 阅读 · 0 评论 -
LeetCode刷题笔记:有效的括号
Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of ...原创 2018-09-04 20:10:14 · 423 阅读 · 0 评论 -
LeetCode刷题笔记:颠倒二进制位
Reverse bits of a given 32 bits unsigned integer. Example Input: 43261596 Output: 964176192 Explanation: 43261596 represented in binary as 00000010100101000001111010011100, return ...原创 2018-09-04 10:58:51 · 414 阅读 · 0 评论 -
LeetCode刷题笔记:汉明距离
The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. Note: 0 ≤ x, y <...原创 2018-09-01 21:14:22 · 341 阅读 · 0 评论 -
LeetCode刷题笔记:位1的个数
Write a function that takes an unsigned integer and returns the number of ‘1’ bits it has (also known as the Hamming weight). Example 1: Input: 11 Output: 3 Explanation: Integer 11 has binary repr...原创 2018-09-01 20:55:27 · 272 阅读 · 0 评论 -
LeetCode刷题笔记:两个数组的交集 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 time...原创 2018-08-13 21:58:03 · 398 阅读 · 0 评论 -
cin.tie与sync_with_stdio加速时输入输出(转)
以前碰到cin TLE的时候总是傻乎乎地改成scanf,甚至还相信过C++在IO方面效率低下的鬼话,殊不知这只是C++为了兼容C而采取的保守措施 tie tie是将两个stream绑定的函数,空参数的话返回当前的输出流指针 #include <iostream> #include <fstream> ///////////////////////////Su...转载 2018-07-31 19:46:09 · 487 阅读 · 0 评论 -
错误C4146的解决方法
错误C4146的解决方法 error C4146: 一元负运算符应用于无符号类型,结果仍为无符号类型; 那么什么情况下会遇见这种错误呢,例如下代码: 错误代码1: int number = -2147483648; //error C4146: 一元负运算符应用于无符号类型,结果仍为无符号类型; 错误代码2: if ( num >= -2147483648 &...转载 2018-08-01 21:52:48 · 2650 阅读 · 0 评论 -
LeetCode刷题笔记:买卖股票额最佳时机 ||
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 on...原创 2018-07-30 22:20:33 · 327 阅读 · 0 评论 -
LeetCode刷题笔记:旋转数组
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 = 3 Output: [5,6,7,1,2,3,4] Explanation: rotate 1 steps to the right:...原创 2018-07-31 11:31:58 · 375 阅读 · 0 评论 -
LeetCode刷题笔记:删除链表的倒数第N个节点
Given a linked list, remove the n-th node from the end of list and return its head. Example: Given linked list: 1-&gt;2-&gt;3-&gt;4-&gt;5, and n = 2. After removing the second node from the end...原创 2018-08-02 20:51:16 · 4869 阅读 · 0 评论 -
LeetCode刷题笔记:存在重复
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 i...原创 2018-07-31 18:51:06 · 435 阅读 · 0 评论