自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

private_void的博客

记录一只渣的leetcode之路。代码有原创,有参考

  • 博客(42)
  • 收藏
  • 关注

转载 最长回文串问题

题目:Given a string S, find the longest palindromic substring in S.给出一个字符串S,找到一个最长的连续回文串。例如串babcbabcbaccba 最长回文是:abcbabcba这个题目给出3中解法,前两种的都是 O(n^2), 第三种思路是O(n).思路1. 动态规划这里动态规划的思路是 dp[i]...

2019-07-11 18:04:38 252

原创 java基础总结

1 HashMap与HashTable1)HashMap在实现时对null做了特殊处理,将null的hashCode值定为了0,从而将其存放在哈希表的第0个bucket中 2)HashMap/HashTable内部用Entry数组实现哈希表;对于映射到同一个哈希桶(数组的同一个位置)的键值对,使用Entry链表来存储(解决hash冲突) 3)HashTable默认的初始大小为11,之后每次...

2019-07-11 17:59:59 1813

转载 Dijkstra算法

原文地址:http://blog.csdn.net/stanfordzhang/article/details/66265841. Dijkstra's Algorithm是解决单源最短路径问题,即:从某个源点到其余各顶点的最短路径;2. Dijkstra's Algorithm中有两上关键点要注意(这是我学习的时候不仔细,导致走了很多弯路)。这里先明确两个集合:所有顶

2015-06-25 15:07:43 492

转载 扔鸡蛋问题详解(Egg Dropping Puzzle)

原文地址:http://blog.csdn.net/joylnwang/article/details/6769160经典的动态规划问题,题设是这样的:如果你有2颗鸡蛋,和一栋36层高的楼,现在你想知道在哪一层楼之下,鸡蛋不会被摔碎,应该如何用最少的测试次数对于任何答案楼层都能够使问题得到解决。如果你从某一层楼扔下鸡蛋,它没有碎,则这个鸡蛋你可以继续用如果这个鸡蛋摔碎了

2015-06-25 15:06:05 473

转载 字符串匹配的KMP算法

原文地址:http://www.ruanyifeng.com/blog/2013/05/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm.html写的很好,转过来备查。字符串匹配是计算机的基本任务之一。举例来说,有一个字符串"BBC ABCDAB ABCDABCDABDE",我想知道,里面是否包含另一个字符串"ABCDABD"?

2015-06-25 14:33:04 294

转载 Java:类与继承

原文地址:http://www.cnblogs.com/dolphin0520/p/3803432.htmlJava:类与继承  对于面向对象的程序设计语言来说,类毫无疑问是其最重要的基础。抽象、封装、继承、多态这四大特性都离不开类,只有存在类,才能体现面向对象编程的特点,今天我们就来了解一些类与继承的相关知识。首先,我们讲述一下与类的初始化相关的东西,然后再从几个方面

2015-06-23 09:53:59 1830

转载 #146 LRU Cache

转自:http://www.cnblogs.com/springfor/p/3869393.html。写在开头,以示尊重。题目:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get a

2015-06-11 11:36:52 500

转载 数据挖掘之聚类算法

原文地址:http://www.blogjava.net/mlh123caoer/articles/51836.html一, 什么是聚类?聚类: - 将一个对象的集合分割成几个类,每个类内的对象之间是相似的,但与其他类的对象是不相似的。评判聚类好坏的标准: 1 ,能够适用于大数据量。 2 ,能应付不同的数据类型。 3 ,能够发现不同类型的聚类。 4 ,使对专业知识的要求降到最低。 

2015-06-04 16:01:42 2064

原创 #110 Balanced Binary Tree

题目:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node ne

2015-06-03 16:08:22 286

原创 #219 Contains Duplicate II

题目:Given an array of integers and an integer k, find out whether there there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is a

2015-06-02 21:23:43 377

原创 #36 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 partia

2015-06-02 20:12:28 332

原创 #101 Symmetric Tree

题目:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3Bu

2015-06-02 20:00:45 369

原创 #102 Binary Tree Level Order Traversal & #107 Binary Tree Level Order Traversal II

题目:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9

2015-06-01 22:24:30 375

原创 #118 Pascal's Triangle & #119 Pascal's Triangle II

题目:Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].题解:

2015-05-31 19:43:07 312

原创 #111 Minimum Depth of Binary Tree & #104 Maximum Depth of Binary Tree

题目:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.

2015-05-31 11:58:28 343

转载 #172 Factorial Trailing Zeroes

题目:Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.题解:看到一篇讲解非常好的文章,所以这题就转载吧。对n!做质因数分解n!=2x*3y*5z*...

2015-05-31 11:29:49 333

原创 #160 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 ↘

2015-05-29 11:34:57 303

原创 #21 Merge Two Sorted Lists

题目:

2015-05-29 10:33:33 251

原创 #88 Merge Sorted Array

题目:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) to h

2015-05-28 15:14:04 239

原创 #168 Excel Sheet Column Title &&#171 Excel Sheet Column Number

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

2015-05-27 17:34:33 322

原创 #20 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 "()[]{}" are

2015-05-27 10:11:38 249

原创 #112 Path Sum

题目:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree

2015-05-27 09:53:36 242

原创 #209 Minimum Size Subarray Sum

题目:Given an array ofnpositive integers and a positive integers, find the minimal length of a subarray of which the sum ≥s. If there isn't one, return 0 instead.For example, given the arr...

2015-05-26 17:08:35 277

原创 #217 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 every ele

2015-05-26 16:08:11 281

原创 #55 Jump Game

题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.De

2015-05-26 10:33:18 285

原创 #169 Majority Element

题目:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority

2015-05-26 09:53:35 263

原创 #53 Maximum Subarray最大子串和

题目:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−

2015-05-25 15:55:08 243

转载 int与integer的区别

int与integer的区别从大的方面来说就是基本数据类型与其包装类的区别:int 是基本类型,直接存数值,而integer是对象,用一个引用指向这个对象1.Java 中的数据类型分为基本数据类型和复杂数据类型int 是前者而integer 是后者(也就是一个类);因此在类进行初始化时int类的变量初始为0.而Integer的变量则初始化为null.2.初始化时:  int i

2015-05-25 09:41:51 963

原创 #189 Rotate Array

题目: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 as many solution

2015-05-22 09:49:46 335

原创 #29 Divide Two Integers

题目:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.题解:不用乘,除,模操作完成除法运算。只能加减了,但逐个减效率低,肯定超时,想不出来,参考了http://blog.csdn.net/perf

2015-05-21 16:55:15 343

原创 #17 Letter Combinations of a Phone Number有问题

题目:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input

2015-05-21 15:38:32 314

原创 #19 Remove Nth Node From End of List

题目:Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the

2015-05-21 15:05:37 226

原创 #83 Remove Duplicates from Sorted List

题目:Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3题解:没啥好说的,这个得遍历一

2015-05-21 13:18:55 317

原创 #58 Length of Last Word

题目:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: 

2015-05-21 12:16:01 261

原创 #125 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."race a car" 

2015-05-20 18:49:38 243

原创 #155 Min Stack

题目:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top(

2015-05-20 15:39:28 268

原创 #67 Add Binary

题目:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".题解:对两个字符串要从最后一位开始加,注意两字符串长度可能不一致,所以需要有补齐。循环结束后,要判断是否有最后进位public c

2015-05-20 10:23:00 332

原创 #66 Plus One

题目如下:Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.整数按位存储于in

2015-05-20 09:59:04 314

原创 #28 Implement strStr()

Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The signature of the function had been updated

2015-05-12 10:01:41 260

原创 #16 3Sum Closest

题目如下:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would hav

2015-05-11 23:38:50 246

空空如也

空空如也

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

TA关注的人

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