- 博客(257)
- 收藏
- 关注
原创 【Leetcode】646. Maximum Length of Pair Chain
DescriptionYou are given n pairs of numbers. In every pair, the first number is always smaller than the second number.Now, we define a pair (c, d) can follow another pair (a, b) if and only if b &...
2018-08-09 12:44:17
267
原创 CFR反编译工具
简介CFR是一个反编译工具,有时我们开发的时候可能会用到反编译,常见的java反编译工具有javap,jad,CFR等。今天主要讲的是CFR的简单使用。最常见的使用方式:java -jar .\cfr_0_132.jar AssertTest.class把.class文件和cfr的jar放在同一个文件夹下,运行命令行就可得到反编译代码。Code//源代码public enum D...
2018-08-08 17:51:31
2342
原创 【Leetcode】36. Valid Sudoku
DescriptionDetermine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:Each row must contain the digits 1-9 without repetition.Each colu...
2018-08-08 10:00:11
301
原创 【Leetcode】712. Minimum ASCII Delete Sum for Two Strings
DescriptionGiven two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal.Example 1:Input: s1 = "sea", s2 = "eat"Output: 231Explanation: Deleting "s" fro...
2018-08-08 00:45:18
303
原创 leetcode :Valid Palindrome
DescriptionGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we define empty string as valid palin...
2018-07-26 10:14:12
266
原创 LeetCode 279. Perfect Squares
题目Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n.Example 1:Input: n = 12Output: 3 Explanation: 12 = 4 + 4 + 4....
2018-06-25 20:21:52
298
原创 leetcode 572.Subtree of Another Tree
题目Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all of this ...
2018-06-19 12:31:11
242
原创 统计数字
描述计算数字k在0到n中的出现的次数,k可能是0~9的一个值样例例如n = 12, k = 1, 在[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 我们发现1出现了5次(1, 10, 11, 12)题解要从1到ABCDE中找到k这个数字在某一位上出现了多少次有以下几种情况:当某一位的数字小于K时,那么该位出现的次数为:更高位...
2018-06-19 11:47:27
285
原创 无序数组中的最小k个数
题目描述对于一个无序数组,数组中元素为互不相同的整数,请返回其中最小的k个数,顺序与原数组中元素顺序一致。给定一个整数数组A及它的大小n,同时给定k,请返回其中最小的k个数。测试样例 [1, 2, 3, 4], 4, 2 返回:[1, 2]解析import java.util.*;public class KthNumbers { pub...
2018-05-29 18:38:29
599
原创 leetcode 154. Find Minimum in Rotated Sorted Array II
题目 Follow up for “Find Minimum in Rotated Sorted Array”: What if duplicates are allowed? Would this affect the run-time complexity? How and why?Suppose an array sorted in ascending or...
2018-03-14 12:26:15
241
原创 Leetcode 118. Pascal's Triangle
题目Given numRows, generate the first numRows of Pascal’s triangle.For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]解法一class Solution...
2018-03-14 10:59:54
294
原创 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 by modifying the input array in-...
2018-03-14 10:04:51
198
原创 leetcode 84. Largest Rectangle in Histogram
题目Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width of ...
2018-03-09 23:27:13
206
原创 leetcode 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->...
2018-03-09 17:47:01
311
原创 leetcode 82. Remove Duplicates from Sorted List II
题目Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example, Given 1->2->3->3->4->4->5, return 1...
2018-03-09 15:16:54
281
原创 leetcode 81. Search in Rotated Sorted Array II
题目 Follow up for “Search in Rotated Sorted Array”: What if duplicates are allowed? Would this affect the run-time complexity? How and why?Suppose an array sorted in ascending order is rot...
2018-03-09 14:41:08
231
原创 leetcode 74. Search a 2D Matrix
题目 Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row ...
2018-03-09 13:46:34
201
原创 leetcode 73. Set Matrix Zeroes
题目Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up: Did you use extra space? A straight forward solution using
2018-03-09 11:16:39
185
原创 leetcode 72. Edit Distance
题目Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a
2018-03-09 10:29:22
240
原创 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 all
2017-12-27 16:27:03
195
原创 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 end,
2017-12-27 16:25:12
195
原创 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 solu
2017-12-27 15:00:24
200
原创 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-12-27 11:19:33
270
原创 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 e
2017-12-27 11:18:52
281
原创 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). Fin
2017-12-22 08:40:01
179
原创 leetcode 10. Regular Expression Matching
题目Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cove
2017-12-22 08:38:32
250
原创 leetcode 9. Palindrome Number
题目Determine whether an integer is a palindrome. Do this without extra space.解析class Solution { public boolean isPalindrome(int x) { if (x 0 || (x != 0 && x % 10 == 0)) {
2017-12-22 08:37:58
197
原创 leetcode 7. Reverse Integer
题目Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123 Output: 321 Example 2:Input: -123 Output: -321 Example 3:Input: 120 Output: 21 Note: Assume we ar
2017-12-22 08:37:09
211
原创 leetcode 6. 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 N A P L S
2017-12-22 08:36:28
238
原创 leetcode 5. Longest Palindromic Substring
题目Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example:Input: "babad"Output: "bab"Note: "aba" is also a
2017-12-22 08:35:13
158
原创 leetcode 4. Median of Two Sorted Arrays
题目There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1: nums1 = [1, 3] n
2017-12-22 08:30:24
183
原创 leetcode 3. Longest Substring Without Repeating Characters
题目Given a string, find the length of the longest substring without repeating characters.Examples:Given “abcabcbb”, the answer is “abc”, which the length is 3.Given “bbbbb”, the answer is “b”, with the
2017-12-22 08:28:00
202
原创 leetcode 2. Add Two Numbers
题目: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 numbers and
2017-12-22 08:25:55
163
原创 leetcode 1. Tow 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 the s
2017-12-22 08:24:53
227
原创 hdu 2089 不要62
杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。 杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。 不吉利的数字为所有含有4或62的号码。例如: 62315 73418 88914 都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉
2017-11-08 09:51:15
213
原创 Hiho 1032 最长回文子串
时间限制:1000ms单点时限:1000ms内存限制:64MB描述 小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助,在编程的学习道路上一同前进。 这一天,他们遇到了一连串的字符串,于是小Hi就向小Ho提出了那个经典的问题:“小Ho,你能不能分别在这些字符串中找到它们每一个的最长回文子串呢?”
2017-11-07 18:34:52
378
原创 Hiho_1015:KMP算法
1015:KMP 算法题目解答:import java.util.Arrays;import java.util.Scanner;public class Main{ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scann
2017-11-06 16:18:32
275
原创 hiho 1039:字符串消除
时间限制:1000ms单点时限:1000ms内存限制:256MB描述小Hi最近在玩一个字符消除游戏。给定一个只包含大写字母"ABC"的字符串s,消除过程是如下进行的:1)如果s包含长度超过1的由相同字母组成的子串,那么这些子串会被同时消除,余下的子串拼成新的字符串。例如"ABCCBCCCAA"中"CC","CCC"和"AA"会被同时消除,余下"AB"和"B"拼成新的字符
2017-10-30 21:10:49
391
原创 正整数分组
题目描述:2组的和相差最小。例如:1 2 3 4 5,将1 2 4分为1组,3 5分为1组,两组和相差1,是所有方案中相差最少的。输出输出这个最小差输入示例512345输出示例1import java.util.Scanner;/** * 正整数分组 */public class PosInter
2017-10-23 10:39:08
519
原创 LIS
题目描述:给出长度为N的数组,找出这个数组的最长递增子序列。(递增子序列是指,子序列的元素是递增的)例如:5 1 6 8 2 4 5 10,最长递增子序列是1 2 4 5 10。输出输出最长递增子序列的长度。输入示例8516824510输出示例5import java.util.Scanne
2017-10-23 09:45:33
323
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人