![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode Online Judge
文章平均质量分 59
梁奎
这个作者很懒,什么都没留下…
展开
-
LeedCode(3) - Longest Substring Without Repeating Characters
题目描述: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length i原创 2016-01-14 13:40:31 · 251 阅读 · 0 评论 -
LeetCode - Add Two Numbers
题目描述: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i原创 2016-01-14 11:42:03 · 224 阅读 · 0 评论 -
LeetCode(35)-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 may assume no duplicates in原创 2016-01-28 20:11:00 · 197 阅读 · 0 评论 -
LeetCode(34)-Search for a Range
问题描述: Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order of O(log n). If the target is原创 2016-01-28 18:06:04 · 196 阅读 · 0 评论 -
LeetCode(33)-Search in Rotated Sorted Array
问题描述: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target value to search. If found in the原创 2016-01-28 14:36:59 · 214 阅读 · 0 评论 -
LeetCode(32)-Longest Valid Parentheses
问题描述: Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the longest valid parentheses substring原创 2016-01-28 14:35:30 · 193 阅读 · 0 评论 -
LeetCode(31)-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 lowe原创 2016-01-26 20:49:04 · 210 阅读 · 0 评论 -
LeetCode -Two Sum
1.Two Sum 题目描述: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up原创 2016-01-10 10:49:29 · 114 阅读 · 0 评论 -
LeetCode(30)-Substring with Concatenation of All Words
问题描述: You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in wordsexactly原创 2016-01-26 20:35:55 · 204 阅读 · 0 评论 -
LeetCode(4) - Median of Two Sorted Arrays
题目描述: There are two sorted arrays nums1 and nums2 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)). 分析: 1. 本题可以采用me原创 2016-01-14 14:23:45 · 239 阅读 · 0 评论 -
LeetCode(37)-Sudoku Solver
问题描述: Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character '.'. You may assume that there will be only one unique solution.原创 2016-03-03 10:34:57 · 144 阅读 · 0 评论 -
LeetCode(41)-First Missing Positive
问题描述: 问题分析: 问题求解:原创 2016-07-08 17:35:51 · 180 阅读 · 0 评论 -
LeetCode(36)-Valid Sudoku
问题描述: Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled with the character '.'. A part原创 2016-01-28 21:57:00 · 204 阅读 · 0 评论 -
LeetCode(26)-Remove Duplicates from Sorted Array
问题描述: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in pl原创 2016-01-24 22:13:27 · 184 阅读 · 0 评论 -
Swap Nodes in Pairs
问题描述: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant spa原创 2016-01-24 21:18:07 · 832 阅读 · 0 评论 -
LeetCode(21)-Merge Two Sorted Lists
问题描述: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 问题分析: 合并两个有序的链表,考察对链表的操作,比较经典的题目 解题方法; /**原创 2016-01-24 14:04:24 · 218 阅读 · 0 评论 -
LeetCode - TwoSum
1.Two Sum 题目描述: Given an arrayof integers, find two numbers such that they add up to a specific targetnumber.The function twoSum should return indices of the two numbers such thatthey add up to the原创 2016-01-10 14:37:09 · 216 阅读 · 0 评论 -
LeetCode(40)-Combination Sum II
问题描述: Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be used once in原创 2016-03-03 19:59:39 · 193 阅读 · 0 评论 -
LeetCode(39)-Combination Sum
问题描述: Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from C unl原创 2016-03-03 17:12:47 · 195 阅读 · 0 评论 -
LeetCode(38)-Count and Say
问题描述: The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is r原创 2016-03-03 12:00:42 · 185 阅读 · 0 评论 -
LeetCode(29)-Divide Two Integers
问题描述: Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 问题分析: 实现除法,不能用乘法,除法和求余 1) 用减法,可能会超时。 2)在1的基础上优化,将除数翻倍(位运算) 分析:题目意思很原创 2016-01-26 20:33:52 · 262 阅读 · 0 评论 -
LeetCode(28)-Implement strStr()
题目描述: Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 题目分析: 在一个字符串中查找另一个字符串,如果查找成功返回字符串头索引,否则返回-1。有两种求解方法: (1原创 2016-01-26 15:35:17 · 206 阅读 · 0 评论 -
LeetCode(15)-3Sum
问题描述: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: Elements in a triplet原创 2016-01-23 15:14:55 · 386 阅读 · 0 评论 -
LeetCode(14)-Longest Common Prefix
题目描述: Write a function to find the longest common prefix string amongst an array of strings. 问题分析: 给一定一个vector & strs,求最大公共前缀子串。 解法一: class Solution { public: string longestCommonPrefix(vec原创 2016-01-22 22:39:56 · 179 阅读 · 0 评论 -
LeetCode(13)-Roman to Integer
问题描述: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. Subscribe to see which companies asked this question 问题分析: 罗马数字原创 2016-01-22 21:28:54 · 216 阅读 · 0 评论 -
LeetCode(12)- Integer to Roman
问题描述: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 问题分析:原创 2016-01-22 18:10:02 · 197 阅读 · 0 评论 -
LeetCode(11)-Container With Most Water
问题描述: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i原创 2016-01-22 18:08:43 · 162 阅读 · 0 评论 -
LeetCode(10) - Regular Expression Matching
问题描述: Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the enti原创 2016-01-22 18:05:41 · 185 阅读 · 0 评论 -
LeetCode(9) - Palindrome Number
问题描述: Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of原创 2016-01-22 15:30:03 · 171 阅读 · 0 评论 -
LeetCode(8) - String to Integer (atoi)
问题描述: Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possib原创 2016-01-22 15:11:16 · 189 阅读 · 0 评论 -
LeetCode(6) - 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 N原创 2016-01-19 22:39:56 · 258 阅读 · 0 评论 -
LeetCode(16)-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 hav原创 2016-01-23 15:52:35 · 174 阅读 · 0 评论 -
LeetCode(17)-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:Dig原创 2016-01-23 20:35:17 · 308 阅读 · 0 评论 -
字符串匹配之有限自动机
模式匹配问题:给一个字符串text: txt[0..n-1] 和 一个模式串 pattern :pat[0..m-1],写一个函数 search(char pat[], char txt[]) 打印模式pat在txt中出现的所有位置。通俗点说就是在一个字符串中定位另一个串的算法。 例子: 1)输入: txt[] = “THIS IS A TEST TEXT” pat[] = “TES转载 2016-01-26 16:03:35 · 454 阅读 · 0 评论 -
字符串匹配之朴素字符串匹配算法
朴素字符串匹配算法英文叫Brute force,大致意思是暴力求解。该算法通过一个循环找到所有的有效偏移s,该循环对n-m+1个可能的s值进行检测,看是否满足条件P[1..m] = T[s+1..s+m]。其中T为待匹配的文本,P为要匹配的模式,如下图所示(摘自算法导论):原创 2016-01-26 15:51:06 · 325 阅读 · 0 评论 -
LeetCode(27)-Remove Element
问题描述: Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It doesn't matter what you leave beyond the new l原创 2016-01-26 10:42:08 · 170 阅读 · 0 评论 -
LeetCode(25)-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. If the number of nodes is not a multiple of k then left-out nodes in the end should remain a原创 2016-01-24 21:20:24 · 190 阅读 · 0 评论 -
LeetCode(23)-Merge k Sorted Lists
问题描述: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 问题分析: 和21题一样,两个有序链表合并和K个有序链表合并思路一致。 1)本题可以利用Merge Two Sorted Lists,用二分法,先两两合并,规模就缩小了原来的一半原创 2016-01-24 17:38:10 · 300 阅读 · 0 评论 -
LeetCode(22)-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: "((()))", "(()())", "(())()", "()(())",原创 2016-01-24 14:55:24 · 175 阅读 · 0 评论 -
LeetCode(20)-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, "()" and "()[]{}" are al原创 2016-01-24 13:57:42 · 168 阅读 · 0 评论