自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

PaladinDu的专栏

PaladinDu的POJ之路以及各种杂记

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

原创 brainfuck解析器

尝试写了一个解释器,顺便测试了下,挺有趣的。看了下brainfuck的语法,极其简单。

2023-09-18 20:40:37 148

原创 简单2D几何求交点

外侧不相交,包含不相交,包含一个点交点,包含圆心两个交点,外部一个交点,外部两个交点。在这个工具中,已经定义的数据结构有点,线段,有向线段,射线,直线,多边形,和圆。需要注意的是,如果是内包的情况,选择较小的圆的圆心作为起始的需要将方向反转。对于两个交点的情况使用了三角形三边求角度,然后旋转圆心向量的方式得到交点。不相交的情况可以通过两个圆心的距离与两个半径的和和差的大小比较过滤。特殊的,对于重叠的圆,可以通过圆心相同排除。线段,有向线段,射线,直线本质都是线段;1.直线过圆心O的垂直线与直线的交点A。

2023-09-14 21:30:00 187

原创 CodeBook 可以自定义字符集的密码本

项目描述 CodeBook是一个可以指定字符集的加密算法。可以在不膨胀的情况下对原文进行加密。项目地址 https://github.com/PaladinDu/CodeBook.git产生的原因 基于安全原因,我们时常需要对数据进行加密。然而一般的加密算法通常是无法指定字符集的。这会导致一个问题,如果我们希望密文是可读文本(一般明文也是)时,需要进行转换(一般base64/hex),这会导致密文数据发生膨胀。CodeBook因此而生。CodeBo...

2020-11-23 00:04:08 621 1

原创 leetcode 1392. Longest Happy Prefix

A string is called ahappy prefixif is anon-emptyprefix which is also a suffix (excluding itself).Given a strings. Return thelongest happy prefixofs.Return an empty string if no such prefi...

2020-03-22 21:28:43 243

原创 leetcode 1388. Pizza With 3n Slices

There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:You will pickanypizza slice. Your friend Alicewill picknext slice in anti clockwise di...

2020-03-22 21:26:10 6026

原创 leetcode 381. Insert Delete GetRandom O(1) - Duplicates allowed

Design a data structure that supports all following operations inaverageO(1)time.Note: Duplicate elements are allowed.insert(val): Inserts an item val to the collection. remove(val): Remove...

2020-03-19 12:32:22 109

原创 leetcode 363. Max Sum of Rectangle No Larger Than K

Given a non-empty 2D matrixmatrixand an integerk, find the max sum of a rectangle in thematrixsuch that its sum is no larger thank.Example:Input: matrix = [[1,0,1],[0,-2,3]], k = 2Output: ...

2020-03-19 12:27:08 113

原创 leetcode 354. Russian Doll Envelopes

You have a number of envelopes with widths and heights given as a pair of integers(w, h). One envelope can fit into another if and only if both the width and height of one envelope is greater than th...

2020-03-19 12:10:30 130

原创 leetcode 352. Data Stream as Disjoint Intervals

Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen so far as a list of disjoint intervals.For example, suppose the integers from the data stream are ...

2020-03-17 17:59:45 130

原创 leetcode 335. Self Crossing

You are given an arrayxofnpositive numbers. You start at point(0,0)and movesx[0]metres to the north, thenx[1]metres to the west,x[2]metres to the south,x[3]metres to the east and so on. ...

2020-03-17 10:20:28 131

原创 leetcode 330. Patching Array

Given a sorted positive integer arraynumsand an integern, add/patch elements to the array such that any number in range[1, n]inclusive can be formed by the sum of some elements in the array. Retu...

2020-03-17 10:16:30 124

原创 leetcode 329. Longest Increasing Path in a Matrix

Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside o...

2020-03-17 10:03:26 137

原创 leetcode 321. Create Maximum Number

Given two arrays of lengthmandnwith digits0-9representing two numbers. Create the maximum number of lengthk <= m + nfrom digits of the two. The relative order of the digits from the same ar...

2020-03-16 17:41:27 107

原创 leetcode 316. Remove Duplicate Letters

Given a string which contains only lowercase letters, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order ...

2020-03-16 17:12:53 108

原创 leetcode 315. Count of Smaller Numbers After Self

You are given an integer arraynumsand you have to return a newcountsarray. Thecountsarray has the property wherecounts[i]is the number of smaller elements to the right ofnums[i].Example:...

2020-03-16 12:29:42 253

原创 leetcode 312. Burst Balloons

Givennballoons, indexed from0ton-1. Each balloon is painted with a number on it represented by arraynums. You are asked to burst all the balloons. If the you burst ballooniyou will getnums[le...

2020-03-16 11:27:02 120

原创 leetcode 301. Remove Invalid Parentheses

Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.Note:The input string may contain letters other than the parentheses(and)....

2020-03-16 09:36:21 104

原创 leetcode 1383. Maximum Performance of a Team

There arenengineers numbered from 1 tonandtwo arrays:speedandefficiency, wherespeed[i]andefficiency[i]represent the speed and efficiency for the i-th engineer respectively.Return the maxi...

2020-03-15 12:35:09 331

原创 leetcode 297. Serialize and Deserialize Binary Tree

Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be...

2020-03-12 09:47:17 159

原创 拍照解数独之识别数独图片

之前做leetcode 37. Sudoku Solver的时候就想,做一个拍照解数独的小玩具应该挺有趣的。这几天折腾了一翻终于有些结果。先看下最终效果原图:目标:目标图是还原后的数独图片。分割成9*9的小格子就可以做识别了。可惜之前做的OCR使用的正常图片进行学习的,对这种被拉伸变形还有些残缺不全的图片效果差的不行。OCR得重新做了。速度也是慢的可以,一张图片得要30多秒了。还...

2020-03-11 10:31:35 8189 6

原创 leetcode 295. Find Median from Data Stream

Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.For example,[2,3,4], the median ...

2020-03-10 18:17:47 157

原创 leetcode 273. Integer to English Words

Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231- 1.Example 1:Input: 123Output: "One Hundred Twenty Three"Example 2:Input:...

2020-03-10 17:47:24 127

原创 leetcode 239. Sliding Window Maximum

Given an arraynums, there is a sliding window of sizekwhich is moving from the very left of the array to the very right. You can only see theknumbers in the window. Each time the sliding window m...

2020-03-09 21:26:02 137

原创 leetcode 233. Number of Digit One

Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.Example:Input: 13Output: 6 Explanation: Digit 1 occurred in the following nu...

2020-03-09 21:08:34 143

原创 leetcode 1377. Frog Position After T Seconds

Given an undirected treeconsisting ofnvertices numbered from 1 ton. A frog starts jumpingfrom thevertex 1. In one second, the frogjumps from itscurrentvertex to anotherunvisitedvertex if th...

2020-03-08 17:47:09 226

原创 leetcode 1373. Maximum Sum BST in Binary Tree

Given abinary treeroot, the task is to return the maximum sum of all keys ofanysub-tree which is also a Binary Search Tree (BST).Assume a BST is defined as follows:The left subtree of a node c...

2020-03-08 17:39:49 360

原创 leetcode 224. Basic Calculator

Implement a basic calculator to evaluate a simple expression string.The expression string may contain open(and closing parentheses), the plus+or minus sign-,non-negativeintegers and empty sp...

2020-03-07 10:54:21 117

原创 leetcode 218. The Skyline Problem

A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you aregiven the locations and height of all the buildingsas...

2020-03-07 10:33:18 152

原创 leetcode 214. Shortest Palindrome

Given a strings, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation.Example 1:...

2020-03-06 11:49:32 130

原创 leetcode 212. Word Search II

Given a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horiz...

2020-03-06 09:56:26 141

原创 leetcode 188. Best Time to Buy and Sell Stock IV

Say you have an array for which thei-thelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at mostktransactions.Note:You may not en...

2020-03-06 09:48:08 91

原创 leetcode 174. Dungeon Game

The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially pos...

2020-03-05 13:45:06 200

原创 leetcode 164. Maximum Gap

Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Return 0 if the array contains less than 2 elements.Example 1:Input: [3,6,9,1]Output: 3...

2020-03-05 13:32:48 124

原创 leetcode 154. Find Minimum in Rotated Sorted Array II

Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7]might become [4,5,6,7,0,1,2]).Find the minimum element.The array may contai...

2020-03-05 13:15:23 137

原创 leetcode 149. Max Points on a Line

Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.Example 1:Input: [[1,1],[2,2],[3,3]]Output: 3Explanation:^|| o| o| o +-----...

2020-03-05 12:24:13 96

原创 leetcode 145. Binary Tree Postorder Traversal

Given a binary tree, return thepostordertraversal of its nodes' values.Example:Input:[1,null,2,3] 1 \ 2 / 3Output:[3,2,1]Follow up:Recursive solution is trivial, coul...

2020-03-05 10:32:16 114

原创 leetcode 140. Word Break II

Given anon-emptystringsand a dictionarywordDictcontaining a list ofnon-emptywords, add spaces insto construct a sentence where each word is a valid dictionary word.Return all such possible ...

2020-03-05 09:55:57 100

原创 leetcode 135. Candy

There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least one ca...

2020-03-04 14:57:03 83

原创 leetcode 132. Palindrome Partitioning II

Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs.Example:Input:"aab"Output: 1Explana...

2020-03-04 14:16:39 135

原创 leetcode 128. Longest Consecutive Sequence

Given an unsorted array of integers, find the length of the longest consecutive elements sequence.Your algorithm should run in O(n) complexity.Example:Input:[100, 4, 200, 1, 3, 2]Output: 4Ex...

2020-03-04 13:01:17 86

空空如也

空空如也

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

TA关注的人

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