- 博客(17)
- 资源 (4)
- 收藏
- 关注
原创 [LeetCode]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 return the list as 2->1->4->3.Your algorithm should use only constant space.
2013-06-26 03:45:27 2985 1
原创 [LeetCode] Multiply Strings
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.class Solution {public: string m
2013-06-26 03:11:51 789
原创 [LeetCode] Unique Paths 2
Follow 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 and 0 respectively in the
2013-06-21 02:29:08 1052
原创 [LeetCode] Unique Paths
A 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 time. The robot is trying to reach th
2013-06-21 02:19:13 1216
原创 [LeetCode]Remove N-th Node from the end of the list
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, t
2013-06-20 08:48:56 806
原创 [leetCode] Integer to Roman
罗马字母规则见:https://zh.wikipedia.org/wiki/%E7%BD%97%E9%A9%AC%E6%95%B0%E5%AD%97因为相减减数只能是一位而且不能跨位数,相加同一个字母不能超过三个,所以可以先用一张对应表将相减能得到的数表示出来,并表述出4*10^n.class Solution {public: string intToRoman(int num
2013-06-20 03:26:04 944
原创 [LeetCode] Search Insert Position
class Solution {public: int searchInsert(int A[], int n, int target) { // Start typing your C/C++ solution below // DO NOT write int main() function int size=n; if
2013-06-20 01:19:48 721
原创 GNUPLOT绘制直方图和error bar的脚本
gnuplot<<EOFset terminal pngset output "result_$1_$2.png"#set xtics rotate by -45#set boxwidth 1 relativeset yrange [0:*]set style histogram errorbars gap 0 lw 3set style data histogramsset xl
2013-06-19 08:10:31 4625
原创 [leetcode]Anagrams
Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.class Solution {public: vector anagrams(vector &strs) { // Start t
2013-06-19 08:03:35 824
原创 [leetCode] Simplify Path
Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"Corner Cases:Did you consider the case w
2013-06-18 10:22:46 898
原创 [Leetcode] Search a 2-D matrix
Write 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 from left to right.The first integer o
2013-06-18 04:27:51 658
原创 [LeetCode] Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees ofevery node never diff
2013-06-17 23:38:17 600
原创 [LeetCode] Implement strStr()
Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.1. 暴力比较,过慢,无法通过大数据集合class Solution {public: char *strStr(char *haysta
2013-06-10 10:12:34 768
原创 [LeetCode] Distinct Subsequences
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 new string which is formed from the original string by deleting some (can be n
2013-06-09 07:08:24 2837
原创 [leetcode]Merge Sorted Array
Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space to hold additional elements from B. The number of elements initialized in
2013-06-05 01:10:18 626
原创 [LeetCode] Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you devis
2013-06-04 04:39:40 3228
原创 [leetcode] Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total nu
2013-06-04 02:52:22 804
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人