在不考虑多线程的情况下,很多类代码都是完全正确的,但是如果放在多线程环境下,这些代码就很容易出错,我们称这些类为 线程不安全类 。多线程环境下使用线程安全类 才是安全的。下面是一个线程不安全类的例子:public class Account { private Integer balance; pu...
分类:
编程语言 时间:
2015-05-26 22:58:07
阅读次数:
148
IntervalsTime Limit:2000MSMemory Limit:65536KTotal Submissions:22781Accepted:8613DescriptionYou are given n closed, integer intervals [ai, bi] and n i...
分类:
其他好文 时间:
2015-05-26 20:55:30
阅读次数:
173
Reverse Integer
题目:
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321 题意:
给你一个整型数,要求返回它的反转数,题目说的很清楚了,但是需要注意的一点就是整型溢出的情况,如果溢出我们返回0。 思路:
我偷懒了用...
分类:
其他好文 时间:
2015-05-26 18:52:05
阅读次数:
109
Problem Description
I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.
Input
The first line of the input contains an integer T(1
Output
F...
分类:
其他好文 时间:
2015-05-26 18:47:18
阅读次数:
148
Palindrome NumberTotal Accepted:57795Total Submissions:194286My SubmissionsQuestionSolutionDetermine whether an integer is a palindrome. Do this witho...
分类:
其他好文 时间:
2015-05-26 18:26:29
阅读次数:
149
http://www.lintcode.com/en/problem/longest-increasing-continuous-subsequence-ii/# Give you an integer matrix (with row size n, column size m),find the...
分类:
其他好文 时间:
2015-05-26 17:54:40
阅读次数:
123
Reverse IntegerTotal Accepted:73207Total Submissions:281775My SubmissionsQuestionSolutionReverse digits of an integer.Example1:x = 123, return 321Exam...
分类:
其他好文 时间:
2015-05-26 15:58:48
阅读次数:
124
http://www.lintcode.com/en/problem/longest-increasing-continuous-subsequence/# Give you an integer array (index from 0 to n-1, where n is the size of ...
分类:
其他好文 时间:
2015-05-26 12:19:11
阅读次数:
144
这是一道很标准的大整数加法,我却wa了4次,没提交一次就查到一些细节问题,比如说我们考虑前导
0的问题,还有就是没有对输入数组处理, 使得他们每次输入时高位的置0,还有就是没考虑到最后相加后的进位,
这些问题一一改正之后,还是wa了,原来是因为,我把if语句中的==只写了一个。。。真坑啊,,,我就说怎么会
不过,明明写的对的,大数相加竟然还wa了四次,还有就是这道题最后不写换行也会wa。。。...
分类:
其他好文 时间:
2015-05-26 09:19:36
阅读次数:
205
这道题看上去比较简单,但是需要注意的细节和情况的处理还是很多的。
(1) 注意负数
(2)注意10,100这类数字的反转
(3) 最容易忽视的一点,整型的溢出。(2333333339反转超int)
注意我们计算的过程中不需要另外存数字,直接计算就好。处理溢出我们先用long long储存,超int后直接返回0
其实我们发现,(1)和(2)都不需要特殊处理,在运算的过程中会自行处理。
c...
分类:
其他好文 时间:
2015-05-26 09:18:36
阅读次数:
97