- 博客(19)
- 收藏
- 关注
原创 关于Arrays.copyOfRange一个易错点
Arrays.copyOfRange方法可以实现对一个数组一定范围内元素的拷贝。其函数原型为:static type copyOfRange(type[] a, int start, int end)参数:a 类型为8大基本类型的数组。start 起始下标(包含这个值)。end 终止下标(不包含这个值)。使用方法如:int [] s1 = {1,2,3,4,5};int [] ...
2018-03-15 23:29:52 2706 6
原创 算法 习题8.22 题解
ProblemIn task scheduling, it is common to use a graphrepresentation with a node for each task and a directed edge from taskito task j if i is a precondition for j. This directedgraph depicts the
2018-01-20 19:40:55 334
原创 Leetcode代码学习周记——Number Complement
题目链接:https://leetcode.com/problems/number-complement/description/题目描述:Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary repres
2018-01-20 19:30:02 228
原创 Leetcode代码学习周记——Merge Two Binary Trees
题目链接:https://leetcode.com/problems/merge-two-binary-trees/description/题目描述:Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees
2018-01-20 19:18:40 198
原创 Leetcode代码学习周记——Find Anagram Mappings
题目链接:https://leetcode.com/problems/find-anagram-mappings/description/题目描述:Given two lists Aand B, and B is an anagram of A. B is an anagram of A means B is made by randomizing the or
2018-01-20 19:07:48 251
原创 Leetcode代码学习周记——3Sum
题目链接:https://leetcode.com/problems/3sum/description/题目描述: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 wh
2018-01-20 18:16:36 205
原创 Leetcode代码学习周记——Longest Common Prefix
题目链接:https://leetcode.com/problems/longest-common-prefix/description/题目描述:Write a function to find the longest common prefix string amongst an array of strings.编写一个函数以查找一个字符串数组中所有字符串的最长公共前
2018-01-20 17:14:28 242
原创 Leetcode代码学习周记——Palindrome Number
题目链接:https://leetcode.com/problems/palindrome-number/description/题目描述:Determine whether an integer is a palindrome. Do this without extra space.判断一个整数是否为回文整数。题解:先排除复数和非0的10的倍数。随后从该整数
2018-01-20 16:20:48 184
原创 Leetcode代码学习周记——Longest Palindromic Substring
题目链接:https://leetcode.com/problems/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.给定一个字
2018-01-13 21:48:52 172
原创 算法练习——前K小数
题目描述:给定一个数组,输出该数组前K小数(无需排序)示例:Input: nums = {38, 61, 7, 87, 81, 18, 50, 55, 90, 26} K = 7Output: result = {7, 18, 26, 38, 50, 55, 61}题解:这道题目有两种解题方法,一是使用排序的算法让数组从小到大排好序,然后依次输出数组的前K个整数。这
2017-12-16 17:31:13 748
原创 Leetcode代码学习周记——Self Dividing Numbers
题目链接:https://leetcode.com/problems/self-dividing-numbers/description/题目描述:A self-dividing number is a number that is divisible by every digit it contains.For example, 128 is a self-div
2017-12-16 15:35:48 243
原创 Leetcode代码学习周记——Sqrt(x)
题目链接:https://leetcode.com/problems/sqrtx/description/题目描述:Implement int sqrt(int x).Compute and return the square root of x.x is guaranteed to be a non-negative integer.实现函数
2017-12-11 20:35:18 248
原创 Leetcode代码学习周记——Judge Route Circle
题目链接:https://leetcode.com/problems/judge-route-circle/description/题目描述:Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, wh
2017-12-10 22:11:10 188
原创 Leetcode代码学习周记——Hamming Distance
题目链接:https://leetcode.com/problems/hamming-distance/description/题目描述:The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
2017-12-10 21:49:41 218
原创 Leetcode代码学习周记——Container With Most Water
题目链接:https://leetcode.com/problems/container-with-most-water/description/题目描述:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical
2017-10-15 14:32:45 201
原创 Leetcode代码学习周记——Reverse Integer
原题目链接:https://leetcode.com/problems/reverse-integer/description/题目描述:反转一个整数的数位。实例:x = 123,return 321 x = -123,return -321注意:输入假定为32位有符号整数。当反转的整数溢出时,您的函数应返回0。除了题目给出的限制,还应该
2017-10-03 21:42:19 242
原创 Leetcode代码学习周记——Longest Substring Without Repeating Characters
原题目链接:https://leetcode.com/problems/longest-substring-without-repeating-characters/description/题目描述:给定一个字符串,求其最长的没有重复字符的子字符串长度。实例:给定 "abcabcbb", 答案为 "abc", 长度为3。给定 "bbbbb",答案为 "b
2017-09-21 10:36:18 226
原创 Leetcode代码学习周记——Add Two Nmubers
原题目链接:https://leetcode.com/problems/add-two-numbers/description/题目描述:给定两个表示了非负整数的链表。数字以相反的顺序存储,每个节点包含一个数字。把两个数相加并将其以链表的形式返回。给定的两个数除了0自身不含首位为0的。实例:输入: (2 -> 4 -> 3) + (5 -> 6 -> 4)输出: 7
2017-09-16 16:08:13 326
原创 Leetcode代码学习周记——Two Sum
原题目链接:https://leetcode.com/problems/two-sum/description/题目描述:给定一个整数数组,返回两个数字的索引,使它们相加得到一个特定的目标值。你可以假设每个输入都只有一个解决方案,而您可能不会使用相同的元素两次。实例:Given nums = [2, 7, 11, 15], target = 9,Because nu
2017-09-10 21:17:46 291
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人