
算法
feifeiiong
这个作者很懒,什么都没留下…
展开
-
A* 寻路算法
写在前面再来填一个坑。之前一直说要写的A* 终于有空补上了,本篇博客首先会介绍最基础的A* 实现,在简单A* 的基础上,尝试实现稍复杂的A* 算法(带有高度信息的地形,允许对角线寻路等)。A*算法简介本博客不准备探讨A* 算法的原理,这里仅仅对A*算法做一个简单介绍,对具体原理感兴趣的同学请查阅相关资料。A* 算法是一种启发式搜索算法。本质上来讲,可以算作是广度优先搜索算法的改原创 2018-02-03 15:27:58 · 3553 阅读 · 0 评论 -
拓扑排序
拓扑排序的DFS解法原创 2017-09-23 22:45:35 · 458 阅读 · 0 评论 -
leetcode 236. Lowest Common Ancestor of a Binary Tree
leetcode 236原创 2017-09-07 15:27:14 · 332 阅读 · 0 评论 -
leetcode 229. Majority Element II
leetcode 229 Majority Element II原创 2017-09-22 21:10:18 · 304 阅读 · 0 评论 -
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 评论 -
leetcode 436. Find Right Interval
leetcode 436 find right interval原创 2017-07-19 10:08:47 · 328 阅读 · 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 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 评论 -
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 评论 -
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 684. Redundant Connection
leetcode 684. Redundant Connection原创 2017-09-25 11:37:19 · 1247 阅读 · 1 评论 -
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 131. Palindrome Partitioning
leetcode 131 palindrome partitioning原创 2017-07-20 23:52:47 · 249 阅读 · 0 评论 -
采样算法(池采样问题 lc 382& lc 398 &洗牌问题)
池采样,采样算法,洗牌算法原创 2017-05-23 11:45:06 · 441 阅读 · 0 评论 -
leetcode 312. Burst Balloons
leetcode 312 burst balloons原创 2017-05-09 12:17:09 · 589 阅读 · 0 评论 -
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 评论 -
leetcode 481. magical string
题目描述A magical string S consists of only ‘1’ and ‘2’ and obeys the following rules: The string S is magical because concatenating the number of contiguous occurrences of characters ‘1’ and ‘2’ generate原创 2017-04-04 21:06:34 · 510 阅读 · 0 评论 -
486. Predict the Winner
leetcode 486 predict the winner原创 2017-04-11 20:39:45 · 321 阅读 · 0 评论 -
leetcode 241. Different Ways to Add Parentheses
different ways to add parentheses原创 2017-04-22 13:52:31 · 215 阅读 · 0 评论