- 博客(34)
- 资源 (2)
- 收藏
- 关注
原创 Spring 松耦合实例
假定我们现在需要输出不同格式文件,传统实现方式如下: 1 创建输出文件接口IGenerateFile.java package com.xidian.edu; public interface IGenerateFile { public void generateFile(); } 2 创建TxtGenerateFile.java、XmlGenerateFile.java实现IG
2017-10-20 16:48:55
1117
原创 JAVA Spring HelloWord实现
IDE:IntelliJ IDEA 2017 HelloWord.java package com.xidian.edu; public class HelloWorld { private String name; public void setName(String name){ this.name=name; } public void
2017-10-19 15:46:00
495
原创 LeetCode算法题——27. 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 constant me
2017-05-05 22:33:40
399
原创 LeetCode算法题——26. Remove Duplicates from Sorted Array
题目: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in p
2017-05-05 22:20:49
411
原创 LeetCode算法题——25. Reverse Nodes in k-Group
题目: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. If the
2017-05-05 21:43:34
350
原创 LeetCode算法题——24. 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
2017-05-05 17:08:00
434
原创 LeetCode算法题——23. Merge k Sorted Lists
题目: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Subscribe to see which companies asked this question. 算法思想: 针对K个排序的链表进行两
2017-05-04 20:24:22
381
原创 LeetCode算法题——22. Generate Parentheses
题目: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: [ "((()))", "(()())", "(())
2017-04-22 21:11:26
356
原创 LeetCode算法题——21. 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-04-12 17:01:42
427
原创 LeetCode算法题——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
2017-04-11 21:47:39
358
原创 LeetCode算法题——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:
2017-04-11 20:53:37
357
原创 LeetCode算法题——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
2017-03-26 21:28:16
482
原创 LeetCode算法题——18. 4Sum
题目: Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Note: The s
2017-03-26 14:45:27
399
原创 LeetCode算法题——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 have
2017-03-24 16:21:03
340
原创 LeetCode算法题——15. 3Sum
题目: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution set must not
2017-03-24 15:11:38
400
原创 LeetCode算法题——14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. 算法思想:逐个比对每个字符串的前缀字符,若出现不相等或者其中某个字符已经是最末尾的字符时,跳出循环。 C++实现如下: #include #include using namespace std; class
2017-03-21 17:12:46
284
原创 LeetCode算法题——13. Roman to Integer
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 针对罗马字符出现的每个位上所有情况考虑进去,得到相应整形数字 class Solution { public: int romanToInt(string
2017-03-21 17:11:27
327
原创 LeetCode算法题——12. Integer to Roman
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 求出所给数字的个、十、百、千位上的数字,然后对应到相应罗马数字字符 class Solution { public: string intToRoman(
2017-03-21 17:10:34
370
原创 LeetCode算法题——11. Container With Most Water
Given 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 line i is at (i, ai) and (i, 0). Find
2017-03-17 12:11:30
332
原创 Python面向对象编程(5)——类的特殊方法
类的特殊方法 1 深入理解类 类本质上也是一个对象,只是其拥有创建自身实例的能力 类可以与变量进行绑定,并且可以为类增加属性 可以把类作为函数的参数传递 2 元类 类的创建和管理者(type),所有的类都是元类的实例 isinstance(Empty,type)查看Empty是否是type的实例 类实例化过程:__new__()、__
2017-03-12 17:06:23
486
原创 LeetCode算法题——Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converting th
2017-03-12 15:25:23
334
原创 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 input ca
2017-03-10 15:38:07
327
原创 LeetCode算法题——Reverse Integer
Description: Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Here are some good questions
2017-03-10 11:18:00
259
原创 LeetCode算法题——Add Two Numbers
Description: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two number
2017-03-09 21:49:24
295
原创 LeetCode算法题——ZigZag Conversion
Description: 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
2017-03-09 21:46:30
411
原创 Python面向对象编程(4)——类的继承与方法重载
类的继承与方法重载 1 继承的特点 减少代码并且灵活的定制新类,子类可以继承父类的属性和方法,但另一方面子类无法继承父类的私有属性和私有方法,子类可以修改父类的方法,也可以定义新的方法。 2 继承的语法定义 方式:在类名之后添加(继承的父类) 多重继承时,括号中放入多个父类名 示例:class myclass(baseclass) 重
2017-03-05 22:10:12
2566
1
原创 Python面向对象编程(3)——类方法、静态方法
类方法、静态方法 1 静态方法 定义形式:@staticmethod装饰,参数不需要self 静态方法无法引用或访问实例属性,可通过类.类变量访问类属性 可以采用类、类实例进行调用 与类相关,但不依赖和改变类和实例 类相关工具方法放在其中,使函数归于类,便于代码的管理 class StaticMethodDemo:
2017-03-05 21:03:26
446
原创 Python面向对象编程(2)——深入类的属性
2 深入类的属性 2.1 同名的类属性与实例属性 在使用实例名.属性名应用时,优先引用实例属性 使用类名.属性名时,只能引用类属性 class ClassAttrDemo1: a=10 def __init__(self): self.a=20 self.b=20 cad1=ClassAttr
2017-03-04 16:15:03
378
原创 Python面向对象编程(1)——属性分类、方法调用
1 面向对象编程 1.1 面向对象编程优点:封装、继承、多态、组合 1.2 类说明采用"""三引号,可用类名.__doc__或者help(类名)查看类说明 1.3 描述对象的特征 1.3.1 实例属性 class ClassDemo2: def __init__(self): self.a=10
2017-03-04 15:48:46
1170
原创 Python基础语法(4)——GUI编程及猜数字游戏
13 图形界面(GUI)及猜数字游戏 1 GUI:Graphical User Interface 2 tkinter:GUI library for Python 3 GUI Example 13.1 图形界面 from tkinter import * import tkinter.messagebox as mb import tkinter.simpledial
2017-03-04 15:46:29
1413
原创 Python基础语法(3)——文件流、异常处理、面向对象编程以及装饰器
10 输入输出 10.1 输入输出方式介绍 可采用input方式接收控制台的输入 str1=input("Please input a string:") print(str1) print("{}".format(str1)) 10.2 IO文件流 写文件 # -*- coding=utf-8 -*- textContext='''\ Cre
2017-03-04 15:40:26
622
原创 Python基础语法(2)——字典、函数定义使用、控制流(if&for&while)
7.3 字典Dictionary(键值对) 创建字典:demoDic={"name":"Tom","age":10,"sex":1} 查看key对应的Value值:demoDic["name"] 删除字典中元素:del demoDic["name"] 清空字典:demoDic.clear() 向字典中插入新的元素:demoDic["sc
2017-03-04 14:53:19
537
原创 Python基础语法(1)—— 输入输出、变量命名规则、List、Tupple等
1 字符串打印采用单引号、双引号均可,三引号用于打印多行字符串 2 format字符串使用: age=3 name="Tom" print("{0} was {1} years old".format(name, age)) 可使用"+"产生同样的输出效果 print(name+" was "+str(age)+" years old") 3 变量命名规则:
2017-03-04 14:49:03
500
原创 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 you may not use th
2017-03-03 20:19:11
481
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人