算法练习
文章平均质量分 75
sasaki_yori
这个作者很懒,什么都没留下…
展开
-
算法练习(1)—— 简单递归/回溯
算法练习(1)—— 简单递归/回溯前言算法课的一环。题目一般都是从leetcode里拿,希望自己在学习中能有所提升吧,也希望自己能坚持下去。习题这次的例题是在 Backtracking 栏目里找的第一题。 标题为 526. Beautiful Arrangement懒得点链接的同学就直接看我下面的搬运吧~ Description Suppose you have N int原创 2017-09-09 01:59:11 · 234 阅读 · 0 评论 -
算法练习(15) —— Unique Paths II
算法练习(15) —— Unique Paths II习题本题取自 leetcode 中的 Dynamic Programming 栏目中的第63题: Unique Paths II题目如下: Description Follow up for “Unique Paths”: Now consider if some obstacles are adde原创 2018-01-10 19:47:58 · 209 阅读 · 0 评论 -
算法练习(14) —— Unique Paths
算法练习(14) —— Unique Paths习题本题取自 leetcode 中的 Dynamic Programming 栏目中的第62题: Unique Paths题目如下: Description A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the dia原创 2018-01-10 19:25:07 · 175 阅读 · 0 评论 -
算法练习(13) —— Reconstruct Itinerary
算法练习(13) —— Reconstruct Itinerary习题本题取自 leetcode 中的 Graph 栏目中的第241题: Reconstruct Itinerary题目如下: Description Given a list of airline tickets represented by pairs of departure and arrival a原创 2018-01-07 21:13:57 · 220 阅读 · 0 评论 -
关于NP完全问题的证明例题
关于NP完全问题的证明例题引NP完全的定义:https://en.wikipedia.org/wiki/NP-completeness与之相关的还有P问题,NP问题,NP难…例题此例题摘自算法概论: The k-SPANNING TREE problem is the following. Input: An undirected g原创 2018-01-13 22:33:16 · 6152 阅读 · 0 评论 -
算法练习(12) —— Different Ways to Add Parentheses
算法练习(12) —— Different Ways to Add Parentheses习题本题取自 leetcode 中的 Divide and Conquer 栏目中的第241题: Different Ways to Add Parentheses题目如下: Description Given a string of numbers and operators, r原创 2018-01-02 13:08:47 · 153 阅读 · 0 评论 -
算法练习(11) —— Split Array Largest Sum
算法练习(11) —— Split Array Largest Sum习题本题取自 leetcode 中的 Dynamic Programming 栏目中的第410题: Split Array Largest Sum题目如下: Description: Given an array which consists of non-negative integers and a原创 2017-12-17 21:09:44 · 152 阅读 · 0 评论 -
算法练习(11) —— Split Array Largest Sum
算法练习(11) —— Split Array Largest Sum习题本题取自 leetcode 中的 Dynamic Programming 栏目中的第410题: Split Array Largest Sum题目如下: Description: Given an array which consists of non-negative integers and a原创 2017-12-17 21:09:34 · 114 阅读 · 0 评论 -
算法练习(11) —— Split Array Largest Sum
算法练习(11) —— Split Array Largest Sum习题本题取自 leetcode 中的 Dynamic Programming 栏目中的第410题: Split Array Largest Sum题目如下: Description: Given an array which consists of non-negative integers and a原创 2017-12-17 21:09:31 · 181 阅读 · 0 评论 -
算法练习(10) —— Frog Jump
算法练习(10) —— Frog Jump习题本题取自 leetcode 中的 Dynamic Programming 栏目中的第403题: Frog Jump题目如下: Description: A frog is crossing a river. The river is divided into x units and at each unit there may原创 2017-12-02 17:35:22 · 386 阅读 · 0 评论 -
算法练习(9)—— Jump Game II
算法练习(9)—— Jump Game II习题本题取自 leetcode 中的 Greedy 栏目中的第45题: Jump Game II题目如下: Description Given an array of non-negative integers, you are initially positioned at the first index of the arra原创 2017-11-20 00:07:35 · 191 阅读 · 0 评论 -
算法练习(8) —— 动态规划
算法练习(8) —— 动态规划习题本次题目取自leetcode中的 Dynamic Programming 栏目中的第698题: Partition to K Equal Sum Subsets题目如下: Description: Given an array of integers nums and a positive integer k, find whether原创 2017-11-12 00:10:52 · 222 阅读 · 0 评论 -
算法练习(5) —— 图
算法练习(5) —— 图习题本次题目取自leetcode中的 Graph 栏目中的第399题: Evaluate Division题目如下: Description Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is原创 2017-10-15 23:58:48 · 146 阅读 · 0 评论 -
算法练习(6) —— 贪心算法
算法练习(6) —— 贪心算法习题本次题目取自leetcode中的 Greedy 栏目中的第135题: Candy题目很简短: Description There are N children standing in a line. Each child is assigned a rating value. You are giving candies原创 2017-10-22 22:57:20 · 301 阅读 · 0 评论 -
算法练习(7) —— 动态规划 Strange Printer
算法练习(7) —— 动态规划 Strange Printer动态规划动态规划算法通常处理的是多阶段的决策最优化问题。挺多的问题都含有递推的思想。做这样的问题,最重要的就是找到对应的状态转移方程。也就是找到了对应的递推公式/递归公式,问题就可以迎刃而解。往往动态规划的实际代码并不算很复杂(至少我现在做到的是这样),但是要理解起来确实有点难度。习题本次题目取自leetcode中的 Dynamic Pr原创 2017-10-30 00:58:28 · 249 阅读 · 0 评论 -
算法练习(4)—— 贪心算法
算法练习(4)—— 贪心算法前言所谓贪心,就是只奔着目前最好的去,按照当前最优的情况去执行,所以按照贪心算法求出的一定是局部的最优解。注意,有可能求不出全局最优解…不过,如果加以合理的改进,贪心算法是可以求出全局最优解的。 正好在算法课之外听了这个算法的讲解,就打算拿道题目来热热身。习题本次题目取自leetcode中的 Greedy 栏目中的第630题: Course Schedule III老原创 2017-09-27 23:57:03 · 387 阅读 · 0 评论 -
算法练习(3)—— 栈
算法联系(3)—— 栈习题本次题目取自leetcode中的 Depth-first Search 栏目中的第394题: Decode String上题: Description Given an encoded string, return it’s decoded string. The encoding rule is: k[encoded_strin原创 2017-09-25 01:11:36 · 379 阅读 · 0 评论 -
算法练习(2)—— 简单分治
算法练习(2)—— 简单分治前言分治不仅仅是分而治之这么一个简单的道理思想,其中蕴含的各种各样的优化方法才是其最大的魅力及难点…很明显大部分这类题目都在复杂度上有一定的要求。 这次做的题目虽然是medium难度,做起来还是相当轻松的~习题这次的题目在leetcode算法题中的Divide and Conquer栏目中的第240题: Search a 2D Matrix II老规矩,上题: D原创 2017-09-17 19:02:21 · 288 阅读 · 0 评论 -
算法练习(16) —— Open the Lock
算法练习(16) —— Open the Lock习题本题取自 leetcode 中的 Breadth-first Search 栏目中的第752题: Open the Lock题目如下: Description You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots:原创 2018-01-10 20:56:38 · 476 阅读 · 0 评论