自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(53)
  • 收藏
  • 关注

原创 LeetCode编程练习 - Valid Parentheses学习心得

题目:      Given a string containing just the characters'(',')','{', '}', '[' and']', determine if the input string is valid.      The brackets must close in the correct order,"()" and"()[]{}" a

2017-09-30 16:40:08 227

原创 LeetCode编程练习 - Intersection of Two Arrays II学习心得

题目:   Given two arrays, write a function to compute their intersection.     Example:     Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return[2, 2].    Note:      1.Each element in the resul

2017-09-28 15:08:55 186

原创 LeetCode编程练习 - Longest Common Prefix学习心得

参考链接:http://blog.csdn.net/zhouworld16/article/details/16882131题目:      Write a function to find the longest common prefix string amongst an array of strings.      编辑一个函数,在字符串数组中找到最长的通用前缀字符串。  

2017-09-27 23:55:13 182

原创 LeetCode编程练习 - K-diff Pairs in an Array学习心得

参考链接:http://blog.csdn.net/zhouziyu2011/article/details/60466898题目:   Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff p

2017-09-27 18:08:22 326

原创 LeetCode编程练习 - Reverse Vowels of a String学习心得

题目:      Write a function that takes a string as input and reverse only the vowels of a string.      Example 1:      Given s = "hello", return "holle".       Example 2:      Given s = "l

2017-09-27 14:29:12 232

原创 LeetCode编程练习 - Reverse String学习心得

题目:  Write a function that takes a string as input and returns the string reversed.      Example:      Given s = "hello", return "olleh".      将字符串反转输出。思路:  之前有遇到一道题Reverse Integer,是将一

2017-09-26 17:50:15 264

原创 LeetCode编程练习 - Move Zeroes学习心得

题目:    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, givennums = [0, 1, 0, 3, 12], after c

2017-09-26 16:50:00 217

原创 LeetCode Linked List & Math & Two Pointers 总结

重温链表Linked List,总结一些问题:   1.链表中如果表示这个链表里没有元素,应该恒等于null,而不是0.(Mergo Two Sorted Lists);   2.在遍历链表的时候,要使用到节点指针,访问是从列表的头部开始移动,遍历整个列表的节点,应该从下一个节点开始做处理。(Remove Duplicates from Sorted List )(Remove Lin

2017-09-26 07:38:38 168

原创 LeetCode编程练习 - Valid Palindrome学习心得

题目:      Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.      For example,      "A man, a plan, a canal: Panama" is a palindrome. 

2017-09-26 01:35:38 278

原创 LeetCode编程练习 - Implement strStr()学习心得

参照链接:http://blog.csdn.net/linhuanmars/article/details/20276833题目:       Implement strStr().        Returns the index of the first occurrence of needle in haystack, or -1 if needle is not par

2017-09-25 22:59:20 191

原创 LeetCode编程练习 - Roman to Integer学习心得

题目:        Given a roman numeral, convert it to an integer.        Input is guaranteed to be within the range from 1 to 3999.    给定一个罗马数字,将其转换为整数,输入保证在从1到3999之间。思路:   查看罗马数字表,I对应1,V对应5

2017-09-25 17:16:42 145

原创 LeetCode编程练习 - Power of Three学习心得

题目:        Given an integer, write a function to determine if it is a power of three.        Follow up:        Could you do it without using any loop / recursion?    给定一个整数,在不使用任何循环/递归的情况下写一个函

2017-09-24 04:34:49 167

原创 LeetCode编程练习 - Missing Number学习心得

题目:       Given an array containingn distinct numbers taken from0, 1, 2, ..., n, find the one that is missing from the array.       For example,       Given nums =[0, 1, 3] return2.      

2017-09-24 04:31:10 141

原创 LeetCode编程练习 - Ugly Number学习心得

2题目:   Write a program to check whether a given number is an ugly number.      Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For example,6, 8 are ugly while14 is n

2017-09-24 04:26:34 312

原创 LeetCode编程练习 - Add Digits学习心得

题目:    Given a non-negative integernum, 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.

2017-09-24 04:20:00 256

原创 LeetCode编程练习 - Power of Two学习心得

题目:    Given an integer, write a function to determine if it is a power of two.    给定一个整数,写一个函数来确定它是否是2的幂。思路:   刚开始想到,只要判断是不是2的倍数就好,但是又想到是2的倍数但又不是2的幂也有,比如说6。查看解决方案,如果一个数是2的幂的话,那它的二进制最高位必然是

2017-09-24 04:16:22 203

原创 LeetCode编程练习 - Factorial Trailing Zeroes学习心得

题目:        Given an integern, return the number of trailing zeroes inn!.        Note:Your solution should be in logarithmic time complexity.    给定一个整数n,返回n!中后面的0的个数。解决方案应该是对数时间复杂度。

2017-09-24 04:13:04 276

原创 LeetCode编程练习 - Excel Sheet Column Number学习心得

题目:    Related to questionExcel Sheet Column Title        Given a column title as appear in an Excel sheet, return its corresponding column number.        For example: A -> 1

2017-09-24 04:08:46 241

原创 LeetCode编程练习 - Count Primes学习心得

题目:        Count the number of prime numbers less than a non-negative number,n.        给定一个非负数n,求小于n的质数的个数。思路:        定义一个变量,初始值为0,用来装载质数,再定义一个变量遍历所有数,因为第一个质数是2,因此,初始值设为2,用布尔值来判断是否是质数,若是质数

2017-09-22 02:27:09 509

原创 LeetCode编程练习 - Happy Number学习心得

题目:   Write an algorithm to determine if a number is "happy".         A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the s

2017-09-22 02:21:55 367

原创 LeetCode编程练习 - Excel Sheet Column Title学习心得

题目:       Given a positive integer, return its corresponding column title as appear in an Excel sheet.       For example: 1 -> A 2 -> B 3 -> C

2017-09-22 02:17:46 233

原创 LeetCode编程练习 - Sqrt(x)学习心得

题目:        Implement int sqrt(int x).        Compute and return the square root ofx.    实现整数倍根号(int x),计算并返回√x。思路:    用Math.Sqrt()开平方就好。      解决方案是以一种数学的形式,也就是牛顿-拉夫森公式(牛顿迭代

2017-09-22 02:15:12 250

原创 LeetCode编程练习 - Add Binary学习心得

题目:       Given two binary strings, return their sum (also a binary string).       For example,       a = "11"       b = "1"       Return "100".    给定两个二进制字符串,返回它们的和(也是一个二进制字符串。)思路:

2017-09-22 02:10:43 204

原创 LeetCode编程练习 - Palindrome Number学习心得

题目:    Determine whether an integer is a palindrome. Do this without extra space.    确定一个整数是否为回文,确保没有额外空间。思路:    在链表中出现过类似的题目,链表中是使用了快慢指针,而在Math中,以三位数为例,只要判断个位和百位相同即可。但显示结果不符。       

2017-09-22 02:05:24 178

原创 LeetCode编程练习 - Reverse Integer学习心得

题目:           Reverse digits of an integer.        Example1: x = 123, return 321        Example2: x = -123, return -321    整数的反向数字。假定输入一个32位的带符号整数。当反向的整数溢出时,函数应该返回0.思路:    以一个三位数为例,按

2017-09-22 02:01:33 165

原创 LeetCode编程练习 - Delete Node in a Linked List学习心得

题目:    Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.    Supposed the linked list is1 -> 2 -> 3 -> 4 and you are given the third nod

2017-09-22 01:58:36 144

原创 LeetCode编程练习 - Palindrome Linked List学习心得

题目:    Given a singly linked list, determine if it is a palindrome.        Follow up:        Could you do it in O(n) time and O(1) space?    给定一个单独对的链表,确定它是否是一个回文(顺读和倒读一样)。思路:

2017-09-22 01:55:52 175

原创 LeetCode编程练习 - Reverse Linked List学习心得

题目:    Reverse a singly linked list.    反向一个单链表。思路:    定义一个空值变量,遍历一个数,就将一个数赋值给这个变量,然后再将下一个指针赋值给这个空下来的位置,然后再将变量赋值给下一个指针,也就是a = b,b = c,c = a。     但是显示为空,后发现在定义下一个指针放在了循环外面,使得遍历不到链表中

2017-09-22 01:52:55 149

原创 LeetCode编程练习 - Remove Linked List Elements学习心得

题目:        Remove all elements from a linked list of integers that have valueval.        Example        Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6,val = 6        Return: 1 --> 2 --> 3 --

2017-09-22 01:47:23 176

原创 LeetCode编程练习 - Intersection of Two Linked Lists学习心得

题目:       Write a program to find the node at which the intersection of two singly linked lists begins.       For example, the following two linked lists: A: a1 → a2

2017-09-22 01:42:09 161

原创 LeetCode编程练习 - Linked List Cycle学习心得

题目:              Given a linked list, determine if it has a cycle in it.       Follow up:       Can you solve it without using extra space?     给定一个链表,在不使用额外空间下确定它是否有一个循环。思路:    查看解决

2017-09-22 01:35:22 181

原创 LeetCode编程练习 - Remove Duplicates from Sorted List学习心得

题目:       Given a sorted linked list, delete all duplicates such that each element appear onlyonce.       For example,       Given 1->1->2, return1->2.       Given 1->1->2->3->3, return1->2->3

2017-09-22 01:31:22 147

原创 LeetCode编程练习 - Merge Sorted Array学习心得

题目:          Given two sorted integer arraysnums1 andnums2, mergenums2 intonums1 as one sorted array.       Note:       You may assume thatnums1 has enough space (size that is greater or

2017-09-22 01:23:44 175

原创 LeetCode编程练习 - Merge Two Sorted Lists学习心得

题目:        Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.        合并两个有序的链表,并返回新链表,新链表应该有这两个链表的头

2017-09-22 01:18:08 160

原创 LeetCode编程练习 - Set Mismatch学习心得

题目:    The set S originally contains numbers from 1 ton. But unfortunately, due to the data error, one of the numbers in the set got duplicated toanother number in the set, which results in repe

2017-09-22 01:11:41 221

原创 LeetCode编程练习 - Longest Harmonious Subsequence学习心得

题目:      We define a harmonious array is an array where the difference between its maximum value and its minimum value isexactly 1.      Now, given an integer array, you need to find the lengt

2017-09-22 01:06:05 193

原创 LeetCode编程练习 - Intersection of Two Arrays学习心得

题目:       Given two arrays, write a function to compute their intersection.       Example:       Given nums1 =[1, 2, 2, 1],nums2 =[2, 2], return[2].       Note:           Each element

2017-09-22 00:59:40 254

原创 LeetCode编程练习 - Valid Anagram学习心得

题目:        Given two stringss andt, write a function to determine ift is an anagram ofs.       For example,       s = "anagram",t = "nagaram", return true.       s = "rat",t = "car", r

2017-09-22 00:47:09 277

原创 LeetCode编程练习 - Contains Duplicate Ⅱ学习心得

题目:    Given an array of integers and an integerk, find out whether there are two distinct indicesi andj in the array such thatnums[i] = nums[j] and theabsolute difference betweeni andj is a

2017-09-22 00:42:25 157

原创 LeetCode编程练习 - Contains Duplicate学习心得

题目:        Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if eve

2017-09-22 00:36:05 195

空空如也

空空如也

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

TA关注的人

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