原创 LeetCode 061. Rotate List

Rotate List   Given a list, rotate the list to the right by k places, where k is non-negative. For example: Give

原创 LeetCode 035. Search Insert Position

Search Insert Position   Given a sorted array and a target value, return the index if the target is found. If no

原创 LeetCode 019. Remove Nth Node From End of List

Remove Nth Node From End of List   Given a linked list, remove the nth node from the end of list and return its

原创 LeetCode 026. Remove Duplicates from Sorted Array

Remove Duplicates from Sorted Array Given a sorted array, remove the duplicates in place such that each element

原创 LeetCode 024. Swap Nodes in Pairs

Swap Nodes in Pairs   Given a linked list, swap every two adjacent nodes and return its head. For example, Given

原创 Leetcode - C++ 目錄

LeetCode - C++ 目錄 LeetCode 001. Two Sum LeetCode 002. Add Two Numbers LeetCode 003. Longest Substring Without Repeat

原创 字符串的排列及組合算法

一、字符串的排列 問題1:輸入一個字符串(無重複字符),打印出該字符串中字符的所有排列。 例如:輸入字符串abc,則打印出由字符a、b、c所能排列出來的所有字符串abc、acb、bac、bca、cab和cba 思路:可以把一個字符串看成兩

原创 LeetCode 017. Letter Combinations of a Phone Number

Letter Combinations of a Phone Number   Given a digit string, return all possible letter combinations that the n

原创 LeetCode 011. Container With Most Water

Container With Most Water   Given n non-negative integers a1, a2, ..., an, where each represents a point at coo

原创 LeetCode 023. Merge k Sorted Lists

Merge k Sorted Lists   Merge k sorted linked lists and return it as one sorted list. Analyze and describe its com

原创 LeetCode 005. Longest Palindromic Substring

Longest Palindromic Substring   Given a string S, find the longest palindromic substring in S. You may assume tha

原创 LeetCode 034. Search for a Range

Search for a Range   Given a sorted array of integers, find the starting and ending position of a given target v

原创 LeetCode 020. Valid Parentheses

Valid Parentheses   Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if

原创 LeetCode 029. Divide Two Integers

Divide Two Integers Divide two integers without using multiplication, division and mod operator. If it is overfl

原创 LeetCode 025. 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 mo