[LeetCode] Valid Anagram
Valid AnagramGiven two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram",...
[LeetCode] Remove Duplicates from Sorted List II
Remove Duplicates from Sorted List IIGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1-&...
Azure搭建SVN服务器及客户端简介
SVN是版本控制器,自从用了它,我就根本离不开他了。团队工作中,用它能够防止冲突,进行版本控制。个人工作中,利用他也能够带来很多方便。首先弄清楚一点,svn分成服务端和客户端。SVN服务器就相当于apache服务器,客户端就相当于浏览器,客户端不会在乎你是哪个软件/哪个系统(Windows下的TortoiseSVN还是Mac下的Versions)。下面我介绍如何在Azure平台上搭建SVN服务器服...
[LeetCode] Search in Rotated Sorted Array II
Search in Rotated Sorted Array IIFollow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a functi...
[LeetCode] Remove Duplicates from Sorted Array II
Remove Duplicates from Sorted Array IIFollow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Y...
[LeetCode] Word Search
Word SearchGiven a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizonta...
[LeetCode] Set Matrix Zeroes
Set Matrix ZeroesGiven a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A straight f...
[LeetCode] Combinations
CombinationsGiven two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ ...
[LeetCode] Simplify Path
Simplify PathGiven an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", =>...
[LeetCode] Unique Paths II
Unique Paths IIFollow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 a...
[LeetCode] Minimum Path Sum
Minimum Path SumGiven a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note:...
[LeetCode] Majority Element II
Majority Element IIGiven an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space. 解题思路:此前做了一道题目...
[LeetCode] Unique Paths
Unique PathsA robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in tim...
[LeetCode] Maximal Square
Maximal SquareGiven a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matrix:1 0 1 ...
[LeetCode] Palindrome Linked List
Palindrome Linked ListGiven a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space? 解题思路:此题的题意为判断单向链表是否为回文。难点就是链表不能随机存取,而且不能反向遍历。一个思想就是找到中间节点,...
[LeetCode] Kth Smallest Element in a BST
Kth Smallest Element in a BSTGiven a binary search tree, write a function kthSmallestto find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST's tot...
[LeetCode] Lowest Common Ancestor of a Binary Tree
Lowest Common Ancestor of a Binary Tree Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest...
[LeetCode] Delete Node in a Linked List
Delete Node in a Linked ListWrite a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 ...
[LeetCode] Lowest Common Ancestor of a Binary Search Tree
Lowest Common Ancestor of a Binary Search TreeGiven a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia...
[LeetCode] Search a 2D Matrix II
Search a 2D Matrix IIWrite an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascendin...