- 博客(17)
- 收藏
- 关注
转载 正则表达式30分钟入门教程
目录跳过目录本文目标如何使用本教程正则表达式到 底是什么东西?入门测试正则表达式元字符字符转义重复字符类分枝条件反义分组后向引用零宽断言负 向零宽断言注释贪婪与懒惰处理选项平衡组/递 归匹配还 有些什么东西没提到联系作者最 后,来点广告……网上的资源及本文参 考文献更新纪录本文目标30分钟内让你明白正则表达式是什么,并对它有一些基本的了解,让你可以在自己的程序或网页里使用它
2015-10-18 09:31:46 310
原创 Peeking Iterator -- leetcode
Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation -- it essentially peek() at the element that will be
2015-10-14 16:58:12 450
原创 Move Zeroes -- leetcode
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling you
2015-10-14 16:03:23 306
原创 Expression Add Operators -- leetcode
算法一,每得到一个新的整数,对其进行+, -, *三种运算。使用dfs递归,免去重复计算。此处使用sum, mul两个变量记录中间结果。 sum 存储累加和, mul 存储乘积结果。之所以用两个,是基于如下情况:1. 当我们在一个整数前添加+号时, 此整数后面紧跟的是*运算的话,我们则不能将此整数运算到sum中2. -号同上3. 当添加*时,我们只需要将该整数累乘进mu
2015-10-14 10:19:42 492
原创 Perfect Squares -- leetcode
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n =
2015-10-10 13:42:34 835
原创 First Bad Version -- leetcode
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the
2015-10-09 11:51:07 398
原创 H-Index II -- leetcode
Follow up for H-Index: What if the citations array is sorted in ascending order? Could you optimize your algorithm?基本思路:折半查找1. 选取中间点,判断该处是否满足hIndex定义2. 如果满足定义,则在左区间继续搜索,以找到更大的hIndex3
2015-10-05 15:08:42 335
原创 H-Index -- leetcode
Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to the definition of h-index on Wikipedia: "A
2015-10-05 10:42:45 652
原创 Integer to English Words -- leetcode
Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.For example,123 -> "One Hundred Twenty Three"12345 -> "Twelve Thousand Th
2015-10-04 12:58:33 398
原创 Missing Number -- leetcode
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For example,Given nums = [0, 1, 3] return 2.Note:Your algorithm shoul
2015-10-03 19:46:01 522
原创 Ugly Number II -- leetcode
Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first
2015-10-03 18:05:17 355
原创 Ugly Number -- leetcode
Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly sinc
2015-10-03 14:46:30 317
原创 Single Number III -- leetcode
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:Given
2015-10-02 15:33:37 273
原创 Add Digits -- leetcode
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has on
2015-10-02 13:46:03 313
原创 Binary Tree Paths -- leetcode
Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]
2015-10-02 12:13:52 284
原创 Valid Anagram -- leetcode
Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:You may ass
2015-10-02 10:37:44 299
原创 Different Ways to Add Parentheses -- leetcode
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +,- and *.Example 1I
2015-10-01 11:34:43 344
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人