![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C#
DMilk
这个作者很懒,什么都没留下…
展开
-
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 · 229 阅读 · 0 评论 -
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 · 276 阅读 · 0 评论 -
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 · 290 阅读 · 0 评论 -
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 · 194 阅读 · 0 评论 -
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 · 151 阅读 · 0 评论 -
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 · 172 阅读 · 0 评论 -
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 · 145 阅读 · 0 评论 -
LeetCode编程练习 - Two Sum学习心得
题目: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and原创 2017-09-21 11:27:20 · 224 阅读 · 0 评论 -
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 · 318 阅读 · 0 评论 -
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 · 209 阅读 · 0 评论 -
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 · 282 阅读 · 0 评论 -
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 · 517 阅读 · 0 评论 -
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 · 374 阅读 · 0 评论 -
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 · 239 阅读 · 0 评论 -
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 · 330 阅读 · 0 评论 -
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 · 264 阅读 · 0 评论 -
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 · 230 阅读 · 0 评论 -
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 · 171 阅读 · 0 评论 -
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 · 188 阅读 · 0 评论 -
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 · 186 阅读 · 0 评论 -
LeetCode编程练习 - Remove Duplicates from Sorted Array学习心得
题目: Given a sorted array, remove the duplicates in place such that each element appear onlyonce and return the new length. Do not allocate extra space for another array, you must do th原创 2017-09-21 15:26:51 · 193 阅读 · 0 评论 -
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 · 247 阅读 · 0 评论 -
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 · 191 阅读 · 0 评论 -
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 · 260 阅读 · 0 评论 -
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 · 238 阅读 · 0 评论 -
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 · 255 阅读 · 0 评论 -
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 · 202 阅读 · 0 评论 -
LeetCode编程练习 - Isomorphic Strings学习心得
题目: Given two stringss andt, determine if they are isomorphic. Two strings are isomorphic if the characters ins can be replaced to gett. All occurrences of a character m原创 2017-09-22 00:29:48 · 207 阅读 · 0 评论 -
LeetCode编程练习 - Single Number学习心得
题目: Given an array of integers, every element appearstwice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you imp原创 2017-09-21 23:45:38 · 214 阅读 · 0 评论 -
LeetCode编程练习 - Rotate Array学习心得
题目: Rotate an array ofn elements to the right byk steps. For example, withn = 7 andk = 3, the array[1,2,3,4,5,6,7] is rotated to[5,6,7,1,2,3,4]. 将n个元素的数组按k级旋转。例如,n = 7和k原创 2017-09-21 23:28:43 · 185 阅读 · 0 评论 -
LeetCode编程练习 - Majority Element学习心得
题目: Given an array of sizen, find the majority element. The majority element is the element that appearsmore than⌊ n/2 ⌋ times. You may assume that the array is non-empty and the maj原创 2017-09-21 23:25:40 · 164 阅读 · 0 评论 -
LeetCode编程练习 - Best Time to Buy and Sell Stock II学习心得
题目: Say you have an array for which theith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as yo原创 2017-09-21 23:18:53 · 190 阅读 · 0 评论 -
LeetCode编程练习 - Best Time to Buy and Sell Stock学习心得
题目: Say you have an array for which theith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one sha原创 2017-09-21 22:58:00 · 174 阅读 · 0 评论 -
LeetCode 编程练习 - Two Sum II - Input array is sorted学习心得
题目: Given an array of integers that is alreadysorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should return indices of原创 2017-09-21 18:05:49 · 301 阅读 · 0 评论 -
LeetCode编程练习 - Plus One学习心得
题目: Given a non-negative integer represented as anon-empty array of digits, plus one to the integer. You may assume the integer do not contain any leading zero, except the number 0 itself.原创 2017-09-21 17:46:41 · 319 阅读 · 0 评论 -
LeetCode编程练习 - Maximum Subarray学习心得
具体参考链接:http://blog.csdn.net/linhuanmars/article/details/21314059题目: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, gi原创 2017-09-21 17:08:18 · 247 阅读 · 0 评论 -
LeetCode编程练习 - Search Insert Position学习心得
题目: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates原创 2017-09-21 16:45:16 · 191 阅读 · 0 评论 -
LeetCode编程练习 - Remove Element学习心得
题目: Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you must do this in place with const原创 2017-09-21 16:23:10 · 190 阅读 · 0 评论 -
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 · 160 阅读 · 0 评论 -
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 · 279 阅读 · 0 评论