
算法分析、Leetcode
文章平均质量分 88
执剑者罗辑
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Simplify Path
对Linux/Unix风格的绝对路径进行简化。原创 2019-10-28 15:20:32 · 437 阅读 · 0 评论 -
Text Justification
Given an array of words and a width *maxWidth*, format the text such that each line has exactly *maxWidth* characters and is fully (left and right) justified. 对给出的字符串数组,根据每行的最大长度限制,进行两端对齐的格式化操作。原创 2019-10-28 12:47:00 · 527 阅读 · 0 评论 -
Valid Number
Validate if a given string can be interpreted as a decimal number.判断给出地字符串是不是实数原创 2019-10-26 22:23:57 · 572 阅读 · 0 评论 -
Permutation Sequence
Given n and k, return the kth permutation sequence.求出n个数字的全排列中的第k个排列。原创 2019-10-25 15:30:25 · 300 阅读 · 0 评论 -
Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.给出一个包含`n`个非负整数的数组,表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。原创 2019-10-22 12:56:53 · 375 阅读 · 0 评论 -
First Missing Positive
Given an unsorted integer array, find the smallest missing positive integer.找出无序int类型数组中,缺失的最小的正整数。原创 2019-10-22 10:59:25 · 391 阅读 · 0 评论 -
Combination Sum
Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target. 找出数组中所有可能的组合,其和等于target。每个元素可以被多次选中。原创 2019-10-21 17:54:05 · 202 阅读 · 0 评论 -
Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells. 数独求解。原创 2019-10-21 15:31:21 · 481 阅读 · 0 评论 -
Longest Valid Parentheses
Given a string containing just the characters `'('` and `')'`, find the length of the longest valid (well-formed) parentheses substring.原创 2019-10-17 18:01:41 · 191 阅读 · 0 评论 -
Divide Two Integers
Divide Two Integers文章目录Divide Two Integers题目分析代码如下题目Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.Return the quotient after d...原创 2019-10-12 18:01:11 · 189 阅读 · 0 评论 -
Reverse Nodes in k-Group
Reverse Nodes in k-Group文章目录Reverse Nodes in k-Group题目分析代码如下题目Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less t...原创 2019-10-11 14:44:48 · 279 阅读 · 0 评论 -
Merge k Sorted Lists
Merge k Sorted Lists文章目录Merge k Sorted Lists题目分析代码如下题目Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3...原创 2019-10-11 11:46:09 · 236 阅读 · 0 评论 -
Remove Nth Node From End of List
Remove Nth Node From End of List文章目录Remove Nth Node From End of List题目分析代码如下题目Given a linked list, remove the n-th node from the end of list and return its head.Example:Given linked list: 1->2...原创 2019-10-11 09:48:42 · 250 阅读 · 0 评论 -
Regular Expression Matching
文章目录Regular Expression Matching题目分析解法1解法2代码如下解法1代码解法2代码Regular Expression Matching题目Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'....原创 2019-10-10 17:16:17 · 343 阅读 · 0 评论 -
Unique Paths(动态规划求解)
给出一个m * n的矩阵,机器人只能向右走或者是向左走。求机器人从右上角到左下角,一共有多少种走法。(使用动态规划求解)原创 2018-10-08 21:38:27 · 361 阅读 · 0 评论 -
Search a 2D Matrix
题目Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer原创 2017-12-18 17:01:38 · 263 阅读 · 0 评论 -
证明 EXACT 4SAT是NP完全问题
题目In the EXACT 4SAT problem, the input is a set of clauses, each of which is a disjunction of exactly four literals, and such that each variable occurs at most once in each clause. The goal is to原创 2018-01-01 15:09:39 · 544 阅读 · 0 评论 -
3Sum Closest
题目Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have原创 2017-12-25 00:20:42 · 144 阅读 · 0 评论 -
Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i原创 2017-09-16 14:52:54 · 211 阅读 · 0 评论 -
Search for a Range
题目Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order ofO(log n).If t原创 2017-10-09 17:13:57 · 341 阅读 · 0 评论 -
Median of Two Sorted Arrays
题目There are two sorted arrays nums1 andnums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1:num原创 2017-10-01 22:05:22 · 216 阅读 · 0 评论 -
Generate Parentheses
题目Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "(()())", "(())()", "()原创 2017-11-06 21:21:59 · 165 阅读 · 0 评论 -
Next Permutation
题目Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest poss原创 2017-10-30 19:27:55 · 347 阅读 · 0 评论 -
3Sum
题目Given an array S of n integers, are there elementsa, b, c in S such that a + b +c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not con原创 2017-10-22 20:33:19 · 365 阅读 · 0 评论 -
罗马数字与阿拉伯数字的相互转化
题目1Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.2Given a roman numeral, convert it to an integer.Input is guaranteed to原创 2017-10-16 14:01:32 · 8720 阅读 · 1 评论 -
Multiply Strings(大整数乘法)
题目Given two non-negative integers num1 and num2 represented as strings, return the product ofnum1 and num2.Note:The length of both num1 and num2 is Both num1 and num2 contains only digits原创 2017-11-12 01:50:20 · 347 阅读 · 0 评论 -
Longest Palindromic Substring(动态规划求解)
题目Given a string s, find the longest palindromic substring ins. You may assume that the maximum length of s is 1000.Example:Input: "babad"Output: "bab"Note: "aba" is also a valid answer.原创 2017-11-20 17:47:11 · 622 阅读 · 0 评论 -
Permutations
题目1. Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2],原创 2017-12-11 19:39:17 · 452 阅读 · 0 评论 -
Letter Combinations of a Phone Number
题目Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit原创 2017-12-11 21:14:44 · 210 阅读 · 0 评论 -
Set Matrix Zeroes
题目Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A straight forward solution using O原创 2017-12-04 01:17:25 · 179 阅读 · 0 评论 -
Palindrome Number
题目Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer to st原创 2017-12-05 19:00:33 · 142 阅读 · 0 评论 -
ZigZag Conversion
题目The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L原创 2017-11-27 01:30:51 · 256 阅读 · 0 评论 -
Pow(x, n)
题目Implement pow(x, n).Example 1:Input: 2.00000, 10Output: 1024.00000Example 2:Input: 2.10000, 3Output: 9.26100原创 2017-12-24 21:59:23 · 1581 阅读 · 0 评论 -
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", which the length is 3.Given "bbbbb", the answer is "b原创 2017-09-24 22:02:38 · 194 阅读 · 0 评论