原创 Reverse Linked List LeetCode206
Reverse Linked List Total Accepted: 5847 Total Submissions: 16863 Reverse a singly linked list. click to show mo
原创 棧的經典問題:括號配對
You are given a string consisting of parentheses() and[]. A string of this type is said to becorrect: (a)if it is the
原创 字符串查找算法kmp
給定一個文本串s,和一個匹配串p,要求查找p第一次在s中出現的位置。 常見的方法如暴力搜素,逐個匹配s[i],p[j],若匹配,下標後移。不匹配,i回溯到這次匹配前的下一位置,j置爲0,重新匹配。最壞情況,時間複雜度O(n*m)。
原创 HDOJ-1002大數相加
參考這篇:點擊打開鏈接 Problem Description I have a very simple problem for you. Given two integers A and B, your job is to calc
原创 Lowest Common Ancestor of a Binary Search Tree leetcode235
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the
原创 Isomorphic Strings leetcode 205
Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be r
原创 Simplify Path Leetcode71
Given an absolute path for a file (Unix-style), simplify it. For example, path = “/home/”, => “/home” path = “/a/./b/
原创 Lowest Common Ancestor of a Binary Tree leetcode236
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition
原创 Multiply Strings leetcode 43
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be ar
原创 Distinct Subsequences leetcode 115
Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a ne
原创 Palindrome Linked List leetcode 234
Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) space? 判
原创 Edit Distance Leetcode 72
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation i
原创 Longest Common Prefix leetcode 14
Write a function to find the longest common prefix string amongst an array of strings. 找所有字符串的公共前綴,簡單地實現題 class Soluti
原创 Clone Graph Leetcode 133
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ’s undirected graph s
原创 ZigZag Conversion leetcode6
The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to displa