摘要:
上课时只听老师说过,Java取余的操作的符号位是和被除数一致的,但不知道为啥例如:-14%3 余数是 -214%-3 余数是 2后来才知道,对余数的定义是 (a/b)*b + a%b 恒等于 a这样的话,-14/3*3的结果是-4*3 = -12,所以余数是-2;14%3同理啦 阅读全文
posted @ 2017-10-21 10:30
link98
阅读(607)
评论(0)
推荐(1)
摘要:
编写递归时,最重要的有以下三点:递归总有一个最简单的情况——方法的第一条语句总是包含一个return的条件语句递归调用总是尝试解决一个规模更小的子问题,这样递归才能收敛到最简单的情况。递归调用的父问题和尝试解决的子问题之间不应该有交集。违背以上原则写出的代码可能是错误的或者低效的。 阅读全文
posted @ 2017-10-21 09:44
link98
阅读(246)
评论(0)
推荐(0)
摘要:
617. Merge Two Binary TreesGiven two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overla... 阅读全文
posted @ 2017-10-20 10:47
link98
阅读(120)
评论(0)
推荐(0)
摘要:
496. Next Greater Element IYou are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next... 阅读全文
posted @ 2017-10-19 22:35
link98
阅读(144)
评论(0)
推荐(0)
摘要:
463. Island PerimeterYou are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are conn... 阅读全文
posted @ 2017-10-19 18:24
link98
阅读(106)
评论(0)
推荐(0)
摘要:
669. Trim a Binary Search TreeGiven a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies... 阅读全文
posted @ 2017-10-18 22:28
link98
阅读(93)
评论(0)
推荐(0)
摘要:
566. Reshape the MatrixIn MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but ... 阅读全文
posted @ 2017-10-17 11:06
link98
阅读(156)
评论(0)
推荐(0)
摘要:
今天写一道LeetCode的题的时候,遇到了List,在new的时候,IDEA的智能提示出现了很多覆盖的方法,我突然觉得奇怪,又想到之前看到的List list = new ArrayList(),就百度了一下。List类是一个接口类,它继承了 Collection 接口。List有两个重要的实现类... 阅读全文
posted @ 2017-10-16 19:31
link98
阅读(333)
评论(0)
推荐(0)
摘要:
412. Fizz BuzzWrite a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead... 阅读全文
posted @ 2017-10-16 19:03
link98
阅读(165)
评论(0)
推荐(0)
摘要:
575. Distribute CandiesGiven an integer array with even length, where different numbers in this array represent different kinds of candies. Each numbe... 阅读全文
posted @ 2017-10-16 16:44
link98
阅读(132)
评论(0)
推荐(0)
浙公网安备 33010602011771号