自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

世靖的码场

AC for AK

  • 博客(237)
  • 资源 (3)
  • 收藏
  • 关注

原创 LeetCode-95-Unique Binary Search Trees II 二叉树

# Definition for a binary tree node# class TreeNode:# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution: # @return a list

2017-10-06 16:17:01 213

原创 LeetCode-94-Binary Tree Inorder Traversal 中序遍历二叉树

# Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution(object): a

2017-10-06 15:30:57 182

原创 LeetCode-93-Restore IP Addresses 暴力

class Solution(object): def restoreIpAddresses(self, s): """ :type s: str :rtype: List[str] """ ans=[] Len=len(s) for i in range(1,4):

2017-10-06 15:20:25 265

原创 LeetCode-92-Reverse Linked List II 链表反转 各种边界条件

# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): def reverseBetween(self, head

2017-10-06 14:56:37 284

原创 LeetCode-91-Decode Ways DP

class Solution(object): dp=[] def numDecodings(self, s): """ :type s: str :rtype: int """ if s=="":return 0 Len=len(s) self.dp=[-1]*(Len

2017-10-06 12:00:51 286

原创 LeetCode-90-Subsets II 暴力dfs回溯

class Solution(object): ans=[] cur=[] ansSet=set() def subsetsWithDup(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ self.an

2017-10-06 10:03:02 291

原创 LeetCode-89-Gray Code

无聊的题目,考Gray Code的概念。。。class Solution(object): def grayCode(self, n): """ :type n: int :rtype: List[int] """ ans=[] for i in range(1<<n):

2017-10-05 15:22:12 181

原创 LeetCode-88-Merge Sorted Array

class Solution(object): def merge(self, nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: voi

2017-10-03 21:57:40 305

原创 菜谱

炒娃娃菜原料:娃娃菜2颗、干辣椒1个、大葱一段、油、盐、酱油、醋步骤:1.将娃娃菜洗净,掰成片,每片切一刀一分为二。大葱切成葱花。干辣椒掰两半。2.倒油,烧热后,放入干辣椒和葱花,炒10秒。3.放入娃娃菜,导入两勺酱油和两勺醋,再加半勺盐。4.炒一炒,出锅。

2017-10-03 21:07:54 377

原创 LeetCode-87-Scramble String DFS+剪枝

class Solution(object): def isScramble(self, s1, s2): """ :type s1: str :type s2: str :rtype: bool """ Len1=len(s1) Len2=len(s2) if

2017-10-03 17:23:32 218

原创 LeetCode-86-Partition List 链表

# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): def partition(self, head, x):

2017-10-03 13:33:38 249

原创 LeetCode-85-Maximal Rectangle 类似上一题,n遍单调栈

class Solution(object): def maximalRectangle(self, matrix): """ :type matrix: List[List[str]] :rtype: int """ Lenx=len(matrix) if Lenx==0:return 0

2017-10-03 11:23:17 311

原创 Python笔记

用Python刷了快一百道题了,语法基本熟悉了,之前很多笔记都写在了那道题的题解里,找起来很麻烦,有时候找不到了很话多用法还是要现去查,我在这里总结一下:list:a=[[0]*10]*10看起来能定义出一个10*10的二维数组,但是我们发现修改其中的一维的数据,其他维的也会被跟着修改,所以这并不是真正意义上的二维数组直接返回最后一个值list[-1]删除某位置,del

2017-10-02 22:47:49 249

原创 LeetCode-84-Largest Rectangle in Histogram 经典题目,单调栈

class Solution(object): def largestRectangleArea(self, heights): """ :type heights: List[int] :rtype: int """ ans=0 heights.append(0) stack=

2017-10-02 22:44:03 272

原创 LeetCode-83-Remove Duplicates from Sorted List 链表水题

# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): def deleteDuplicates(self, he

2017-10-02 20:46:19 204

原创 hiho 1601 背包DP乱搞 [Offer收割]编程练习赛29 Problem C 最大得分

时间限制:10000ms单点时限:1000ms内存限制:256MB描述小Hi和小Ho在玩一个游戏。给定一个数组A=[A1, A2, ... AN],小Hi可以指定M个不同的值S1,S2, S3 ... SM,这样他的总得分是 ΣSi × count(Si)。(count(Si)是数组中与Si相等的元素的个数)。为了增加难度,小Ho要求小Hi选

2017-10-01 16:54:30 469

原创 hiho 1599 dfs乱搞 [Offer收割]编程练习赛29 Problem A 逃离迷宫4

时间限制:10000ms单点时限:1000ms内存限制:256MB描述小Hi被坏女巫抓进一座由无限多个格子组成的矩阵迷宫。小Hi一开始处于迷宫(x, y)的位置,迷宫的出口在(a, b)。小Hi发现迷宫被女巫施加了魔法,假设当前他处在(x, y)的位置,那么他只能移动到(x+y, y)或者(x, x+y)的位置上。小Hi想知道自己能不能逃离迷宫。

2017-10-01 16:47:02 486

原创 LeetCode-82-Remove Duplicates from Sorted List II 链表

# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): def deleteDuplicates(self, he

2017-09-27 19:54:52 242

原创 LeetCode-81-Search in Rotated Sorted Array II 水题

class Solution(object): def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: bool """ for i in range(len(nums)):

2017-09-27 19:24:38 194

原创 LeetCode-80-Remove Duplicates from Sorted Array II 水题

class Solution(object): def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ if nums==[]:return 0 Len=len(nums) for i

2017-09-27 15:50:50 747

原创 LeetCode-79-Word Search 爆搜

class Solution(object): d=[[1,0],[0,1],[-1,0],[0,-1]] used=[] def exist(self, board, word): """ :type board: List[List[str]] :type word: str :rtype: bool

2017-09-27 15:31:10 227

原创 LeetCode-78-Subsets 水题暴力

class Solution(object): ans=[] cur=[] def subsets(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ self.ans=[] self.ans.ap

2017-09-27 14:42:31 225

原创 LeetCode-77-Combinations dfs+剪枝

class Solution(object): ans=[] cur=[] def combine(self, n, k): """ :type n: int :type k: int :rtype: List[List[int]] """ self.ans=[]

2017-09-21 20:49:27 217

原创 LeetCode-76-Minimum Window Substring 尺取法+字典

class Solution(object): def minWindow(self, s, t): """ :type s: str :type t: str :rtype: str """ Map={} Lens=len(s) Lent=len(t)

2017-09-21 20:25:19 183

原创 LeetCode-75-Sort Colors 水题

class Solution(object): def sortColors(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ cnts=[0

2017-09-21 19:09:19 213

原创 LeetCode-74-Search a 2D Matrix 二维二分

class Solution(object): def searchMatrix(self, matrix, target): """ :type matrix: List[List[int]] :type target: int :rtype: bool """ Len=len(matrix)

2017-09-21 18:12:21 221

原创 LeetCode-73-Set Matrix Zeroes 水题

class Solution(object): def setZeroes(self, matrix): """ :type matrix: List[List[int]] :rtype: void Do not return anything, modify matrix in-place instead. """

2017-09-21 17:21:42 257

原创 LeetCode-72-Edit Distance 记忆化搜索DP

class Solution(object): dp=[] def minDistance(self, word1, word2): """ :type word1: str :type word2: str :rtype: int """ self.dp=[[-1 for i in r

2017-09-21 15:25:26 327

原创 LeetCode-71-Simplify Path 无聊模拟

class Solution(object): def simplifyPath(self, path): """ :type path: str :rtype: str """ ans="/" stackLen=1 path+='/' Len=len(path)

2017-09-21 13:16:44 244

原创 LeetCode-70-Climbing Stairs DP水题Fibonacci

class Solution(object): def climbStairs(self, n): """ :type n: int :rtype: int """ if n<=1:return 1 a=1 b=1 c=0 for i in ran

2017-09-21 10:45:44 209

原创 LeetCode-69-Sqrt(x) Python要用math.sqrt()

class Solution(object): def mySqrt(self, x): """ :type x: int :rtype: int """ return int(math.sqrt(x))

2017-09-20 22:43:15 857

原创 LeetCode-68-Text Justification 细节题

很烦的边界条件,还能输入[""],2这种数据的???然后标准输出是["  "],真搞不懂意义何在class Solution(object): def fullJustify(self, words, maxWidth): """ :type words: List[str] :type maxWidth: int :rt

2017-09-20 22:37:45 212

原创 LeetCode-67-Add Binary Python的二十进制互转

注意2进制表示方法是字符串,转出来的二进制带个0b,必要时要去掉class Solution(object): def addBinary(self, a, b): """ :type a: str :type b: str :rtype: str """ return bin(int(a,

2017-09-20 20:27:40 231

原创 LeetCode-66-Plus One 水题

class Solution(object): def plusOne(self, digits): """ :type digits: List[int] :rtype: List[int] """ Len=len(digits) jinwei=1 for i in range

2017-09-20 20:20:14 267

原创 LeetCode-65-Valid Number 脑残暴力

class Solution {public: bool isNumber(string s) { enum InputType { INVALID, SPACE, SIGN, DOT, E, DIGIT, LEN }; int trans[][LEN] = { {-1, 0, 1, 2

2017-09-20 19:55:00 267

原创 LeetCode-64-Minimum Path Sum DP水题

class Solution(object): def minPathSum(self, grid): """ :type grid: List[List[int]] :rtype: int """ Lenx=len(grid) if Lenx==0:return 0 Leny=

2017-09-20 19:28:41 190

原创 LeetCode-63-Unique Paths II DP水题

净喜欢给些非法的输入,各种边界条件,真是无语,注重细节就好,这种题真无聊class Solution(object): def uniquePathsWithObstacles(self, obstacleGrid): """ :type obstacleGrid: List[List[int]] :rtype: int

2017-09-20 19:17:47 195

原创 LeetCode-62-Unique Paths DP水题

class Solution(object): def uniquePaths(self, m, n): """ :type m: int :type n: int :rtype: int """ if m*n==0:return 0 if m==1 or n==1:return

2017-09-20 18:59:00 175

原创 LeetCode-61-Rotate List 链表水题

# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): def rotateRight(self, head, k

2017-09-20 16:32:42 248

原创 LeetCode-60-Permutation Sequence 暴力递归

class Solution(object): ans="" def getPermutation(self, n, k): """ :type n: int :type k: int :rtype: str """ nums=range(1,n+1) ans=[]

2017-09-20 15:37:23 243

编译原理 LR(0)项目集规范族的构造 LR(0)分析表+分析串的代码实现

编译原理作业:输出LR(0)分析表,并且可以判断一个语句是否符合文法。整个过程我是使用codeblocks的c++编写的,其中用了一下STL标准库中的队列、映射。这是实现功能的详细代码,有注释的伪代码以及测试用的相关样例数据。

2015-12-06

编译原理 NFA_DFA 画图 C#

编译原理老师布置的作业要求程序实现NFA_DFA,然后还要输出图像,这个程序是读取一个txt文档数据然后输出一个DFA图,生产txt文档的程序是用c++写的,在我上传的另一个资源里,这两个一起用会有奇效喔

2015-11-28

编译原理NFA-DFA转化原创代码以及算法详解

编译原理老师讲完NFA_DFA布置的作业,因为我是搞ACM的,这个题目用到的算法自己经常用,于是我就用bfs+dfs+状态压缩乱搞搞弄出个代码来,功能ok,100%原创,仅仅提供大家参考。这个是输出的表格部分,我们的程序还支持自动输出dfa的图形,我感觉画图比这个算法还难。。。在另一个资源里再下载。

2015-11-28

空空如也

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

TA关注的人

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