4. Median of Two Sorted Arrays-python

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)).Example 1: nums1 = [1, 3] nums2...
阅读(127) 评论(0)

3.Longest Substring Without Repeating Characters-python

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”, with the le...
阅读(158) 评论(0)

1. Two Sum-python

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 solution, and you may not use the same ele...
阅读(271) 评论(0)

48. Rotate Image

原题You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up: Could you do this in-place?代码实现算法思想: public class Solution { //This is in...
阅读(78) 评论(0)

图像顺时针步进1个像素点的算法

矩阵步进1的算法public void Rotate(int[,] matrix) { int n = matrix.GetUpperBound(0) + 1; int loop = n >> 1; for (int i = 0; i < loop; i++) {...
阅读(75) 评论(0)

34. 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 of O(log n).If the target...
阅读(121) 评论(0)

32. Longest Valid Parentheses

栈的典型应用。能想到栈,但是能想到Push字符索引,真的不是很容易(这道题一般的想法是存储‘(’ ‘)’这些符号)。 原题 Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring....
阅读(291) 评论(0)

18. 4Sum

4个数的和等于固定值,利用3个数的和等于固定值的API Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of tar...
阅读(119) 评论(0)

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.Example1:...
阅读(285) 评论(0)

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 have exa...
阅读(191) 评论(0)

15. 3Sum

这道题最难的是所求解不能包含重复的triplets。原题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: The solution...
阅读(89) 评论(0)

12. Integer to Roman

Integer to Roman...
阅读(194) 评论(0)

5. Longest Palindromic Substring

背景 “回文”是指正读反读都能读通的句子,它是古今中外都有的一种修辞方式和文字游戏,如“我为人人,人人为我”等。在数学中也有这样一类数字有这样的特征,成为回文数(palindrome number)。 设n是一任意自然数。若将n的各位数字反向排列所得自然数n1与n相等,则称n为一回文数。例如,若n=1234321,则称n为一回文数;但若n=1234567,则n不是回文数。 注意:...
阅读(224) 评论(0)

3. 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",...
阅读(93) 评论(0)

172. Factorial Trailing Zeroes

原题 Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 代码实现 计算阶乘n的尾数0的个数 public int TrailingZeroes(int n) {...
阅读(282) 评论(0)

165. Compare Version Numbers

Compare Version Numbers...
阅读(310) 评论(0)

70. Climbing Stairs

70. Climbing Stairs...
阅读(382) 评论(0)

38. Count and Say

原题 The count-and-say sequence is the sequence of integers with the first five terms as following: 1 11 21 1211 111221 1 is read off as “one 1” or 11. 11 is read off as “two 1s” o...
阅读(331) 评论(0)

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. 代码实现 public int StrStr(string haystack, string needle) {...
阅读(188) 评论(0)

19. Remove Nth Node From End of List

19. Remove Nth Node From End of List...
阅读(253) 评论(0)
167条 共9页1 2 3 4 5 ... 下一页 尾页
    Leetcode Solutions in Github

    Click me

    Leetcode solutions in Github, including tags: Array, HashTable, Stack, Queue, LinkedList, Tree, Graph,...

    leetcode-manager

    Click me

    Current Leetcode manager: it's used by Entity Framework, WinForms, Sql Server to manage leetcode questions that we have done. Functions include tags creation, revise and deletion, and questions creation, edit and deletion.

    个人资料
    • 访问:67773次
    • 积分:3612
    • 等级:
    • 排名:第8611名
    • 原创:232篇
    • 转载:0篇
    • 译文:0篇
    • 评论:46条
    博客专栏