Stephen.Ri Blog

You are waiting for a train, a train that will take you far away!

[LeetCode]33. Search in Rotated Sorted Array

  "一个折过一次的有序数组中搜索目标"

Description Suppose an array sorted in ascending order 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 searc...

[LeetCode]29. Divide Two Integers

  "不用乘除和模运算来算整数除法"

Description Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. Discussion 不用乘除和模运算来算整数除法。 最简单而直观的方法就是用被除数一直减除数,直到为0。 另外,我们可以采用左移右移...

[LeetCode]26. Remove Duplicates from Sorted Array

  "从一个有序数组中删除重复数据"

Description 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...

[LeetCode]28. Implement strStr()

  "判断是否是子串"

Description Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Discussion 判断needle是否是haystack的子串,并返回子串的起始位置。 暴力破解法。每次...

[LeetCode]22. Generate Parentheses

  "给出n对括号的所有匹配情况"

Description Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example For example, given n = 3, a solution set is: [ “((()))”, “(()(...

[LeetCode]20. Valid Parentheses

  "括号匹配问题"

Description Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "()" and "()[]{}" ...

[LeetCode]19. Remove Nth Node From End of List

  "从链表中删除倒数第n个节点"

Description Given a linked list, remove the nth node from the end of list and return its head. Example Given linked list: 1->2->3->4->5, and n = 2. After removing the second node ...

[LeetCode]17. Letter Combinations of a Phone Number

  "给出一串数字的所有可能字母组合"

Description 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. Ex...

[LeetCode]21. Merge Two Sorted Lists

  "合并两个有序数组"

Description 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. Discussion 合并排序问题的最后一步。 算法的时间复杂度为O(n)。 ...

[LeetCode]15. 3Sum

  "求3个数的和为定值"

Description 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 set must...