- 博客(24)
- 收藏
- 关注
原创 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 ↘
2016-09-27 23:15:25 230
原创 Hibernate5.x.x创建SessionFactory
//创建一个SessionFactory对象SessionFactory sessionFactory = null; //创建一个StandardServiceRegistry 对象:hibernate 的任何配置和服务都需要在该对象中注册后才能有效//注意导入的包要是hibernate里的包,而且创建也与hibernate4有区别,此工程用的是hibernate5.1.2fin
2016-09-27 21:43:38 497
原创 Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5解题思路:增添一个头结点,让 head 指向该头
2016-09-26 20:01:07 231
原创 LeetCode-Reverse Linked List
Reverse a singly linked list.click to show more hints.Hint:A linked list can be reversed either iteratively or recursively. Could you implement both?非递归解法:维护两个指针变量 prev ,temp,temp 和
2016-09-25 20:35:45 184
原创 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?思路:检验是否为回文我们需要对比对应数字是否相等,首先我们需要找到链表的中点,寻找中点的办法是制定两个指针,一个慢指针、一个快指针,快指针每
2016-09-23 21:32:47 179
原创 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?解题思路:用两个指针来扫描链表,其中一个指针指向前面一个节点,当两个指针重合时必然存在环,否则就不存在;代码如下:
2016-09-23 11:44:37 188
原创 LeetCode-Swap Nodes in Pairs
题目:Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant
2016-09-22 19:33:15 231
原创 LeetCode-House Robber
题目:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjac
2016-09-21 21:30:49 269
原创 LeetCode-Reverse Words in a String
题目:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Update (2015-02-12):For C programmers: Try to solve it in
2016-09-20 14:11:29 315
原创 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.题目意思:拼接连个链表成一个新链表,新链表应该由两个链表中的较小首结点开始,按顺序依次排下去;
2016-09-19 20:09:51 171
原创 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 "()[]{}" are
2016-09-18 20:12:15 173
原创 LeetCode-First Unique Character in a String
题目:Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examples:s = "leetcode"return 0.s = "loveleetcode",return 2.
2016-09-13 19:31:20 310
原创 如何把MyEclipse中的web项目导入到Eclipse中运行
有时我们需要将MyEclipse中的项目导入到Eclipse中运行,如果不注意到一些细节,会造成无法运行的后果。下面就说说具体操作:如何导入到Eclipse就不在重述了,导入后出现如下错误:与上面Eclipse生成的web项目对比发现少了Deployment Descriptor:......这个项,因此我们要把它添加进来,如何添加?首先我们选定刚导入的项目右键打开其属性p
2016-09-12 20:57:51 44442 7
原创 LeetCode-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
2016-09-12 11:42:53 207
原创 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 is 1 -> 2 -> 3 -> 4 and you are given the third node w
2016-09-12 10:48:00 140
原创 LeetCode-Longest Common Prefix
题目:Write a function to find the longest common prefix string amongst an array of strings.思路:用双重循环来实现。外循环控制第一行字符串横向顺序,内控制字符串的纵向行数,内循环依次扫描第i个字符是否与第一个字符串的第i个字符相等;代码如下: helloword
2016-09-11 19:39:49 180
原创 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.解题思路:如果当前数跟前一个数相等,则结果加上当前数;如果当前数小于前一个数,则结果加上前一个数,将当前数赋给前一个数,再取下一个数;如果当前数大于前一个数,
2016-09-10 21:08:04 158
原创 罗马数字
罗马数字一共有七个单位,I(1),V(5),X(10),L(50),C(100),D(500),M(1000),其他数均由这七个单位组合而成。组合规则: 1.一个数重复几次表示为该数的几倍,比如III->3,XXX->30; 2.左加右减,在一个较大的数右边加上一个小的数记为左边大数加上右边小数,比如VI->6,XI->11,在一个较大数的左边加一个较小数时,记为右边大数减去
2016-09-10 19:47:50 1519
原创 LeetCode-Missing Number
题目: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 algori
2016-09-10 12:45:53 201
原创 LeetCode-Palindrome Numbers
题目:Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer
2016-09-08 19:32:05 182
原创 LeetCode-Add Two Numbers
题目:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it
2016-09-07 20:13:46 132
原创 LeetCode-String to Integer (atoi)
题目:Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible
2016-09-06 21:37:50 190
原创 LeetCode-Reverse Integer
题目:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask
2016-09-04 19:02:51 254
原创 LeetCode-ZigZag Conversion
原题陈述:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA
2016-09-01 20:01:25 310
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人