算法分析与设计
刘年大侠
这个作者很懒,什么都没留下…
展开
-
Two Sum
Description:Description: 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 solutio原创 2017-09-10 23:29:21 · 245 阅读 · 0 评论 -
Algorithms(算法概论) Page.263 Exercises 8.10
Algorithms(算法概论) Page.264 Exercises 8.10 8.10. Proving NP-completeness by generalization. For each of the problems below, prove that it is NPcomplete by showing that it is a generalization原创 2017-12-31 22:54:08 · 303 阅读 · 0 评论 -
Happy Number
LeetCode原题:Happy Number Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number原创 2017-12-24 23:42:39 · 224 阅读 · 0 评论 -
Implement strStr()
LeetCode原题:Implement strStr() Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 主要内容:这道题让我们在一个字符串中找另一个字符串第一次出现的位置 解题思想:首先原创 2017-12-04 00:00:05 · 135 阅读 · 0 评论 -
Search Insert Position
LeetCode原题:Search Insert Position Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You m原创 2017-12-10 23:36:41 · 153 阅读 · 0 评论 -
Palindrome Number
LeetCode原题:Palindrome Number Determine whether an integer is a palindrome. Do this without extra space. Spoilers: Could negative integers be palindromes? (ie, -1) If you are thinking of conver原创 2017-11-05 18:51:49 · 144 阅读 · 0 评论 -
Valid Parentheses
LeetCode原题:Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "(原创 2017-11-18 23:37:08 · 117 阅读 · 0 评论 -
Longest Common Prefix
LeetCode原题:Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. 主要内容: 返回给定字符串数组里面所有字符串的最长公共前缀 解题思想: 1.一般以第一个字符串作为对比,将原创 2017-11-12 23:14:16 · 131 阅读 · 0 评论 -
Roman to Integer
罗马数字转阿拉伯数字,以前没有做过这题,但是可能有类似的做过,主要注意的地方: 思路: 分段处理罗马数字,然后将每个段的值相加 其中: 判断如果当前位所指的字符代表的数值等于上一位,则将当前位所指的字符代表的数值添加进用来保存分段值的temp; 判断如果当前位所指的字符代表的数值大于上一位,则用当前位所指的字符代表的数值减去上一位,存入用来保存分段值的temp; 判断如果当前位所指的字原创 2017-10-15 16:51:02 · 162 阅读 · 0 评论 -
Remove Element
leetcode原题:Remove Element Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you must do this in原创 2017-10-29 23:33:38 · 276 阅读 · 0 评论 -
Reverse Integer
leetcode原题:Reverse Integer Description: Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Note: The input is assumed to be a 32-bit signed integ原创 2017-10-29 19:30:20 · 234 阅读 · 0 评论 -
Longest Substring Without Repeating Characters
LeetCode原题:Longest Substring Without Repeating Characters Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc原创 2018-01-14 23:56:47 · 144 阅读 · 0 评论