- 博客(25)
- 收藏
- 关注
转载 Footnote in table
HI, move the \footnotetext commands outside the table environment; this however will cause the footnotes to appear at the bottom of the page (as the first table in my example below shows); if you
2015-01-29 10:53:31 888
转载 std::string to char*
Q: I want to convert a std::string into a char* or char[] data type. std::string str = "string"; char* chr = str; Results in: “error: cannot convert ‘std::string’ to ‘char’ ...”. What methods a
2015-01-25 22:44:40 669
转载 [LeetCode] Dungeon Game
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially pos
2015-01-24 06:58:47 444
转载 [LeetCode] Scramble String 解题报告
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = "great": great / \ gr
2015-01-24 06:55:29 528
转载 LeetCode Text Justification
Text Justification Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You should pack your
2015-01-24 06:37:52 368
转载 LeetCode:Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 合并k个有序的链表,我们假设每个链表的平均长度是n。这一题需要用到合并两个有序的链表子过程 算法1: 最傻的做法就是先1、2合并,12结果和3合并,123结果和4合并,…,1
2015-01-24 06:04:52 588
转载 LeetCode Multiply Strings 高精度乘法C++实现
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. 这道题就是模拟乘法
2015-01-24 03:26:25 561
转载 [LeetCode] Word Break, Solution
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s = "leetcode", dict = ["leet"
2015-01-24 03:20:06 441
转载 Find Peak Element --leetcode
原题链接:https://oj.leetcode.com/problems/find-peak-element/ 题目大意:给定一个相邻元素不相等的数组,找出其中的一个局部最大值,返回对应下标。 方法1:顺序遍历。 本题的一个重要特点是,从第一个元素开始,若其大于相邻的后续元素,则第一个元素就是一个局部最大值,返回即可。若其小于相邻的后续元素,则第二个元素大于第一个元素。如此,一
2015-01-24 03:01:06 490
转载 leetcode Question 83: Restore IP Addresses
Restore IP Addresses: Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example: Given "25525511135", return ["255.255.11.135",
2015-01-24 02:57:44 464
转载 [LeetCode]Maximum Product Subarray
今天准备再刷一遍leetcode,发现出了一道新题。刚开始想贪心一遍O(n)实现,没有想出来。于是从头开始想,暴力双循环,O(n*n)肯定没有问题。然后下午坐车的时候又想到了可以用二分法,后来终于又想出来了O(n)的实现,如下所示,不过怎么感觉自己的实现这么麻烦呢,对0考虑的太多了。后面贴的别人的算法就比较简洁。 Find the contiguous subarray within an
2015-01-24 02:14:58 407
转载 LeetCode(173) Binary Tree Iterator
题目如下: Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the next smallest number in the BST. Note: n
2015-01-24 02:03:40 407
转载 [LeetCode] 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, and there exists one unique longest palindromic substring. » Solve this problem
2015-01-24 00:26:14 530
转载 [LeetCode] Surrounded Regions, Solution
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region . For example, X X X X X O O
2015-01-23 06:09:34 419
转载 std::unique
Defined in header template class ForwardIt > ForwardIt unique( ForwardIt first, ForwardIt last ); (1) template class ForwardIt, class BinaryPredicate > ForwardIt uniqu
2015-01-15 01:30:47 529
转载 Leetcode Distinct Subsequences 动态规划法活用总结
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 origina
2015-01-14 09:42:07 451
转载 leetcode Question 123: Wildcard Matching
Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the". click to show clarification. Clarification: What constitutes
2015-01-14 06:48:17 494
转载 Leetcode OJ: Regular Expression Matching
Regular Expression Matching Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The
2015-01-14 06:30:24 436
转载 leetcode Question: Clone Graph
Clone Graph Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirected graph serialization: Nodes are labeled uniquely. We u
2015-01-14 01:37:28 446
转载 LeetCode Largest Rectangle in Histogram又一个极品程序
Largest Rectangle in Histogram Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogra
2015-01-14 01:17:18 454
转载 LeetCode Gas Station 两个特性,两种方法完美解答-更新证明方法
Gas Station There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel fro
2015-01-13 23:42:48 372
转载 Leetcode笔记(7)Divide Two Integers
Divide two integers without using multiplication, division and mod operator. 又是一道乍看很简单的题目。多年来的考试经验表明:题目越是简单的,解题步骤反而越是纠结。这就是一道典型的例子。 首先第一步要确认思路。乘除取模不能用,剩下+-和其他运算符。不能用乘号,可以用加号来乘二,加到刚好小于被除数为止。然后减
2015-01-13 15:02:21 436
转载 LeetCode:Valid Sudoku,Sudoku Solver(数独游戏)
Valid Sudoku Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled with the character '.'. A partial
2015-01-13 11:03:30 456
转载 LeetCode:Roman to Integer,Integer to Roman
首先简单介绍一下罗马数字,一下摘自维基百科 罗马数字共有7个,即I(1)、V(5)、X(10)、L(50)、C(100)、D(500)和M(1000)。按照下述的规则可以表示任意正整数。需要注意的是罗马数字中没有“0”,与进位制无关。一般认为罗马数字只用来记数,而不作演算。 重复数次:一个罗马数字重复几次,就表示这个数的几倍。 右加左减: 在较大的罗马数字的右边记上较小的罗
2015-01-13 09:58:13 426
转载 C++ STL map的使用
1、map简介 map是一类关联式容器。它的特点是增加和删除节点对迭代器的影响很小,除了那个操作节点,对其他的节点都没有什么影响。对于迭代器来说,可以修改实值,而不能修改key。 2、map的功能 自动建立Key - value的对应。key 和 value可以是任意你需要的类型。根据key值快速查找记录,查找的复杂度基本是Log(N),如果有1000个记录,最多查找10次,1,000,
2015-01-13 05:58:51 473
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人