原创 LeetCode35. 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 i

原创 LeetCode1. Two Sum

題目 Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may

原创 LeetCode9. Palindrome Number

題目 Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: C

原创 LeetCode27. Remove Element

題目 Given an array and a value, remove all instances of that value in place and return the new length. Do not allocat

原创 LeetCode5. Longest Palindromic Substring

題目 Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000

原创 LeetCode38. Count and Say

題目 The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11

原创 LeetCode24. 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

原创 算法證明題8.12 k生成樹問題爲搜索問題和NPC問題

題目: k生成樹問題描述如下: 輸入:無向圖G=(V,E); 輸出:G的一個生成樹,其中所有結點的度數都不超過k(如果存在的話); 證明:對於k>=2,有 1)k生成樹問題爲搜索問題 2)k生成樹問題爲NPC問題 證明如下: 1)首先要

原创 LeetCode19. Remove Nth Node From End of List

題目 Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked l

原创 LeetCode48. Rotate Image

題目 You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: C

原创 LeetCode12. Integer to Roman

題目 Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 思路 先百

原创 LeetCode28. Implement strStr()

題目 Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part

原创 LeetCode33. Search in Rotated Sorted Array

題目 Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6

原创 LeetCode20. Valid Parentheses

題目 Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is v

原创 LeetCode100. Same Tree

題目 Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal