
C++
文章平均质量分 62
feifeiiong
这个作者很懒,什么都没留下…
展开
-
leetcode 713. Subarray Product Less Than K & leetcode 467. Unique Substrings in Wraparound String
写在前面两道类似的题目,解法不一样(哭笑不得.jpg),一道用slidingwindow解,一道DP。713. Subarray Product Less Than K题目描述Your are given an array of positive integers nums.Count and print the number of (contiguous) subar...原创 2018-03-02 21:30:46 · 469 阅读 · 0 评论 -
leetcode 552. Student Attendance Record II & 600. Non-negative Integers without Consecutive Ones
leetcode 552. Student Attendance Record II & 600. Non-negative Integers without Consecutive Ones原创 2017-09-15 21:54:36 · 521 阅读 · 0 评论 -
leetcode 236. Lowest Common Ancestor of a Binary Tree
leetcode 236原创 2017-09-07 15:27:14 · 332 阅读 · 0 评论 -
C++ swap函数(effective C++ 条款25)
swap,std::swap原创 2017-09-14 23:32:30 · 8897 阅读 · 0 评论 -
leetcode 229. Majority Element II
leetcode 229 Majority Element II原创 2017-09-22 21:10:18 · 304 阅读 · 0 评论 -
C++ copy and swap (拷贝交换技术)
拷贝交换技术原创 2017-09-06 15:03:20 · 5907 阅读 · 3 评论 -
leetcode 667. Beautiful Arrangement II
leetcode 667. Beautiful Arrangement II原创 2017-08-28 19:37:33 · 2404 阅读 · 0 评论 -
leetcode 34. Search for a Range (binary search std::lower_bound)
leetcode 34. search for a range原创 2017-08-24 11:45:10 · 325 阅读 · 0 评论 -
leetcode 480. Sliding Window Median
leetcode 480. Sliding Widow Median原创 2017-08-22 20:24:34 · 870 阅读 · 0 评论 -
leetcode 52. N-Queens II & leetcode 51 N-Queens (N皇后问题)
N皇后问题原创 2017-04-17 11:33:22 · 342 阅读 · 0 评论 -
leetcode 219. Contains Duplicate II
leetcode 219. Contains Duplicate II原创 2017-07-28 18:47:26 · 283 阅读 · 0 评论 -
leetcode 354. Russian Doll Envelopes & leetcode 300 Longest Increasing Subsequence
leetcode 354. Russian Doll Envelopes & leetcode 300 Longest Increasing Subsequence原创 2017-07-28 15:08:51 · 306 阅读 · 0 评论 -
leetcode 330. Patching Array
leetcode 330. Patching Array原创 2017-08-03 13:22:32 · 316 阅读 · 0 评论 -
vector::erase & map::erase (C++11)
vector::erase & map::erase原创 2017-08-02 10:50:55 · 2767 阅读 · 4 评论 -
leetcode 25. Reverse Nodes in k-Group & leetcode 92. Reverse Linked List II
leetcode 25. Reverse Nodes in k-Group原创 2017-08-28 19:47:20 · 385 阅读 · 0 评论 -
private 继承(effective C++ 条款40)
private继承原创 2017-09-24 18:18:57 · 388 阅读 · 0 评论 -
leetcode 684. Redundant Connection
leetcode 684. Redundant Connection原创 2017-09-25 11:37:19 · 1247 阅读 · 1 评论 -
最小堆的C++实现
写在前面闲来无事写了个C++版本的最小堆,堆的底层采用数组,基本的上浮和下沉过程请参考算法导论,非常简单。这里不再画图解释,具体的实现代码如下。代码实现template<typename T>class PriorityQueue {private: vector<T> heap;public: PriorityQueue() { ...原创 2018-02-27 13:18:56 · 998 阅读 · 0 评论 -
A* 寻路算法
写在前面再来填一个坑。之前一直说要写的A* 终于有空补上了,本篇博客首先会介绍最基础的A* 实现,在简单A* 的基础上,尝试实现稍复杂的A* 算法(带有高度信息的地形,允许对角线寻路等)。A*算法简介本博客不准备探讨A* 算法的原理,这里仅仅对A*算法做一个简单介绍,对具体原理感兴趣的同学请查阅相关资料。A* 算法是一种启发式搜索算法。本质上来讲,可以算作是广度优先搜索算法的改原创 2018-02-03 15:27:58 · 3553 阅读 · 0 评论 -
leetcode 773. Sliding Puzzle
写在前面好久没写算法题题解了,实在太忙了。每周的contest都有在做,本周的contest 第二题第三题都算比较有趣的题目,也都A了,先整理一下第三题的解题思路。题目描述On a 2x3 board, there are 5 tiles represented by the integers 1 through 5, and an empty square represented b原创 2018-01-28 18:01:11 · 1892 阅读 · 0 评论 -
leetcode 486. Predict the Winner
leetcode 486原创 2017-12-07 11:02:45 · 339 阅读 · 0 评论 -
leetcode 343. Integer Break
leetcode 343. Integer Break原创 2017-11-15 22:07:11 · 219 阅读 · 0 评论 -
leetcode 23. Merge k Sorted Lists
leetcode 23. Merge K Sorted Lists原创 2017-10-14 19:57:01 · 296 阅读 · 0 评论 -
leetcode 653. Two Sum IV - Input is a BST
leetcode 653. Two Sum IV - Input is a BST原创 2017-10-14 19:06:11 · 435 阅读 · 0 评论 -
leetcode 540. Single Element in a Sorted Array
leetcode 540. Single Element in a Sorted Array原创 2017-10-14 18:05:03 · 311 阅读 · 0 评论 -
leetcode 406. Queue Reconstruction by Height
leetcode 406. Queue Reconstruction by Height原创 2017-10-09 23:02:11 · 264 阅读 · 0 评论 -
隐式类型转换与非成员函数(effective C++ 条款24&46)
隐式类型转换,运算符重载原创 2017-09-28 21:33:20 · 417 阅读 · 0 评论 -
leetcode 673. Number of Longest Increasing Subsequence
contest 49 LIS原创 2017-09-10 21:18:34 · 1805 阅读 · 0 评论 -
leetcode 666. Path Sum IV
leetcode 666 contest 43原创 2017-09-01 17:22:02 · 1453 阅读 · 0 评论 -
leetcode 316. Remove Duplicate Letters
leetcode 316 remove duplicate letters原创 2017-09-09 15:27:28 · 324 阅读 · 0 评论 -
leetcode 436. Find Right Interval
leetcode 436 find right interval原创 2017-07-19 10:08:47 · 328 阅读 · 0 评论 -
leetcode 363. Max Sum of Rectangle No Larger Than K
leetcode 363 Max Sum of Rectangle No Larger Than K原创 2017-07-22 21:58:41 · 388 阅读 · 0 评论 -
leetcode 650. 2 Keys Keyboard
leetcode 650. 2 Keys Keyboard原创 2017-07-30 13:45:46 · 1627 阅读 · 1 评论 -
leetcode 328. Odd Even Linked List
leetcode 328 odd even linked list原创 2017-04-20 15:48:47 · 294 阅读 · 0 评论 -
leetcode 516. Longest Palindromic Subsequence
leetcode 516 longest palindromic subsequence原创 2017-05-02 11:43:10 · 387 阅读 · 0 评论 -
leetcode 318. Maximum Product of Word Lengths
leetcode 318 maximum product of word lengths原创 2017-04-19 19:19:43 · 253 阅读 · 0 评论 -
leetcode 206. Reverse Linked List(翻转链表)
这道题的题目描述就跟标题一样了,一个经典问题,基本可以默写出来了,很简单。头插法要创建额外O(n)空间,这里不介绍。 具体代码如下,因为使用了auto,需要在支持C++11的编译器中运行:ListNode* reverseList(ListNode* head) { typedef ListNode* Node; if(head==nullptr) r原创 2017-04-06 10:21:33 · 296 阅读 · 0 评论 -
leetcode 378. Kth Smallest Element in a Sorted Matrix
leetcode 378 Kth Smallest Element in a Sorted Matrix原创 2017-04-14 11:40:24 · 352 阅读 · 0 评论 -
leetcode 494 Target sum
leetcode 494 target sum原创 2017-04-13 21:08:57 · 313 阅读 · 0 评论 -
leetcode 539 & 401
之所以这两题放在一起整理,是觉得两道题目很相近,基本思路一样,而且都是跟时间表示相关的类型。leetcode 539. Minimum Time Difference题目描述:Given a list of 24-hour clock time points in “Hour:Minutes” format, find the minimum minutes difference between a原创 2017-04-05 10:49:20 · 519 阅读 · 0 评论