自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(24)
  • 资源 (1)
  • 收藏
  • 关注

原创 One Edit Distance

161. One Edit Distance题目的原意: 写一个函数判断两个给定的String是否是编辑距离为一。给定条件:两个字符串。解题思路:用one edit的算法会超时,可以利用只有一个编辑的距离的特点。将问题细分为出现一个距离的一下几种情况。              1. 两个字符串长度一样的时候,说明只有一个字符串不一样,所以只需要看对应位置的连个字符是否一致,是否只...

2018-08-31 20:22:26 283

原创 Missing Range

163. Missing Ranges题目的原意是要求返回函数能给出缺失的区间。给定条件:一个排好序数组,指定区间【0, 99】解题思路:可以将题目缩小到如何返回一个指定两个数的数值区间范围。                   解决办法,如果两个数相等,放回单个数作为区间,如果不等则放回区间 数值A->数值B.                 返回到原题,需要对一个比区...

2018-08-17 19:12:17 240

原创 Reverse Words in a String III

557. Reverse Words in a String III题目的原意是用就地操作来实现函数对给定的String中的每个单词进行反转。解题思路1: 1. 反转每个单词。2. 这样需要写一个swap方法来置换单个的词。public String reverseWords(String s){ //convert String into char array ...

2018-07-16 19:01:37 221

原创 Reverse Words in a String

151. Reverse Words in a String题目的原意是写一个函数对给定的String进行逐个单词的反转。e.g. given s = "the sky is blue", return "blue is sky the"要考虑的corner case1. 是什么构建一个单词?一些非空格的字符串组成一个单词。2. tab 和 newline 字符是否算作空格字符? 假设不包含任何t...

2018-07-01 11:19:11 155

原创 Implement strStr()

28. Implement strStr()题目的原意是建立一个方法来可以找到一个String needle 在另外一个String haystack中第一次出现的index。question: Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle i...

2018-06-28 01:10:44 149

原创 two sum III Data structure design

170. two sum III data structure design题目的原意是设计一个带有Add 和 find 方法的 two sum的类。question: design and implements a TwoSum class. it should support the following operations: add and find.add: add the number ...

2018-06-22 01:30:52 245

原创 String to Integer(atoi)

8. String to Integer (atoi)题目的原意是 实现atoi 的方法来将String转换成数值。方法的基本要求: 先去除第一个字母前的空格,然后判断第一个字母看是否是+,-,数字。如果是+给个+符号并且将光标移到下一个字母,如果是-, 给个-符号并且将光标移到下一个字母。 如果是数字,需要将数字的Strng格式的部分转换成数值。例子:Input: "42" O...

2016-01-05 05:03:57 428

原创 II Hash Table: 2. Longest Substring Without Repeating Characters

3. Longest Substring Without Repeating Charactersgiven: a string, find the length of the longest substring without repeating characters.        e.g. the longest substring without repeating letters

2016-01-03 00:21:08 279

原创 II Hash Table: Valid Anagram

1. Valid Anagramgiven: two strings s and t, write a function to determine if t is an anagram of s.e.g.s="anagram", t="nagaram", return true.s="rat", t="car", return false.strategy: u

2016-01-02 23:55:14 342

原创 Product of Array Except Self

238. Product of Array Except Selfgiven: an array of n integers where n>1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].

2016-01-02 21:51:00 265

原创 Container With Most Water

11. Container With Most Watergiven: n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn       such that the two endpoints of li

2016-01-02 20:55:25 309

原创 Valid Palindrome

125. Valid Palindromegiven: a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.e.g. "A man, a plan, a canal: Panama" is a palindrome."race a

2016-01-02 17:37:17 313

原创 Rotate Array

189. Rotate Arrayrequirement: rotate an array of n elements to the right by k steps.for example, with n=7 and k=3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]note: try to come up

2015-12-30 04:14:56 493

原创 Reverse Words in a String II

186. Reverse Words in a String II题目的原意是用就地操作来实现函数对给定的char string 进行逐个单词的反转。存在的挑战: 1. 在不使用split的方法的情况下实现。 2. 旋转array从左到右就地操作,而且不申请额外的空间。 解题思路1: 1. 先反转整个string。2. 再反转单个词。3. 这样需要写一个swap方法来置换...

2015-12-30 03:17:33 352

原创 Two Sum II - Input array is sorted

167. Two Sum II - Input array is sortedGiven: an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.output: the

2015-12-30 00:32:17 355

原创 remove duplicates from sorted Array

Given: a sorted array, to do: remove the duplicates in place such that each element appear only once and return the new lengthrequirment: do not allocate extra space for another array, you m

2015-12-29 21:52:16 308

原创 two sum

question:Given: an array of integers, to do: find two numbers such that they add up to a specific target number.requirement: The function twoSum should return indices of the two numbers    

2015-12-28 01:51:57 280

原创 二分法求函数根

http://www.patest.cn/contests/mooc-ds/03-1二分法求函数根的原理为:如果连续函数f(x)在区间[a, b]的两个端点取值异号,即f(a)f(b)二分法的步骤为:检查区间长度,如果小于给定阈值,则停止,输出区间中点(a+b)/2;否则如果f(a)f(b)如果f((a+b)/2)正好为0,则(a+b)/2就是要求的根;

2015-01-12 22:07:07 2213

原创 数组02鞍点

http://mooc.study.163.com/learn/ZJU-1000002011#/learn/ojhw?id=1000060002Saddle point (鞍点)在微分方程中,沿着某一方向是稳定的,另一方向是不稳定的奇点。在泛函中,既不是极大值点也不是极小值点的临界点。在矩阵中,一个数在所在行中是最大值,在所在列中是最小值。在物理上要广泛一些,指在一个方向是

2015-01-11 00:18:51 675

原创 多项式加法

http://mooc.study.163.com/learn/ZJU-1000002011#/learn/ojhw?id=1000060002题目内容:一个多项式可以表达为x的各次幂与系数乘积的和,比如:现在,你的程序要读入两个多项式,然后输出这两个多项式的和,也就是把对应的幂上的系数相加然后输出。程序要处理的幂最大为100。输入格

2015-01-09 08:33:35 569

原创 念整数

纲要:程序需要读入一个整数 [-100000, 100000]。然后用汉语拼音将每位数输出来。如输入1234,则输出:yi er san si注意,每个字的拼音之间有一个空格,但是最后的字后面没有空格。当遇到负数时,在输出的开头加上“fu”,如-2341输出为:fu er san si yi汉语拼音: li

2015-01-08 14:33:13 677

原创 素数和

如果编译一个关于素数的程序.我们认为2是第一个素数,3是第二个素数,5是第三个素数,依次类推。现在,给定两个整数n和m,0输入格式:两个整数,第一个表示n,第二个表示m。输出格式:一个整数,表示第n个素数到第m个素数之间所有的素数的和,包括第n个素数和第m个素数。#includeint main(){int n, m;scanf(

2014-12-24 23:35:52 948

转载 逆序的三位数

题目内容:程序每次读入一个正三位数,然后输出逆序的数字。注意,当输入的数字含有结尾的0时,输出不应带有前导的0。比如输入700,输出应该是7。输入格式:每个测试是一个3位的正整数。输出格式:输出逆序的数。输入样例:123输出样例:321时间限制:500ms内存限制:32000kb

2014-12-24 07:20:13 439

转载 逆序的三位数

题目内容:程序每次读入一个正三位数,然后输出逆序的数字。注意,当输入的数字含有结尾的0时,输出不应带有前导的0。比如输入700,输出应该是7。输入格式:每个测试是一个3位的正整数。输出格式:输出逆序的数。输入样例:123输出样例:321时间限制:500ms内存限制:32000kb

2014-12-23 12:18:45 444

唐率的简历.html

唐率的简历.html

2021-08-09

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除