2018年3月29日

两个线程分别打印 1- 100,A 打印偶数, B打印奇数

摘要: package com.demo.thread; public class PrintNumber { private static Object lock = new Object(); private static int i = 1; private static int wait = 1; private static final int TOTAL =... 阅读全文

posted @ 2018-03-29 21:40 lina2014 阅读(344) 评论(0) 推荐(0) 编辑

2018年3月26日

一个链表,奇数位升序偶数位降序,让链表变成升序的

摘要: 题目描述:一个链表,奇数位升序偶数位降序,让链表变成升序的。比如:1 8 3 6 5 4 7 2 9,最后输出1 2 3 4 5 6 7 8 9。分析:这道题可以分成三步:首先根据奇数位和偶数位拆分成两个链表。然后对偶数链表进行反转。最后将两个有序链表进行合并。 阅读全文

posted @ 2018-03-26 18:07 lina2014 阅读(1071) 评论(0) 推荐(0) 编辑

LeetCode 046 Permutations 全排列

摘要: Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[ [1,2,3], [1,3,2], [2,1, 阅读全文

posted @ 2018-03-26 17:31 lina2014 阅读(283) 评论(0) 推荐(0) 编辑

LeetCode 128 Longest Consecutive Sequence 一个无序整数数组中找到最长连续序列

摘要: Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest 阅读全文

posted @ 2018-03-26 17:07 lina2014 阅读(219) 评论(0) 推荐(0) 编辑

LeetCode 024 Swap Nodes in Pairs 交换链表中相邻的两个节点

摘要: Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your alg 阅读全文

posted @ 2018-03-26 16:42 lina2014 阅读(105) 评论(0) 推荐(0) 编辑

2018年3月22日

模板实现一个栈(内部使用动态申请的数组作为存储结构)

摘要: 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 template 8 class Stack 9 { 10 public: 11 Stack(){} 12 ~Stack(){} 13 bool empty()const; 14 void push(T value);... 阅读全文

posted @ 2018-03-22 19:00 lina2014 阅读(148) 评论(0) 推荐(0) 编辑

2018年3月21日

004 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 sho 阅读全文

posted @ 2018-03-21 18:56 lina2014 阅读(156) 评论(0) 推荐(0) 编辑

静态链接与动态链接

摘要: 静态链接是指把要调用的函数或者过程直接链接到可执行文件中,成为可执行文件的一部分。也就是函数和过程的代码就在程序的可执行文件中,可执行文件包含了运行时所需的全部代码。 动态链接是指所调用的函数代码并没有被拷贝到应用程序的可执行文件中去,而是仅仅在其中加入了所调用函数的描述信息,往往是一些重定位信息。 阅读全文

posted @ 2018-03-21 10:56 lina2014 阅读(191) 评论(0) 推荐(0) 编辑

sizeof和strlen的区别

摘要: 1、sizeof是操作符,而strlen是库函数; 2、sizeof的参数可以为任意变量或类型,而strlen必须以char*做参数,且字符串必须以‘/0’结尾; 3、数组名用作sizeof参数时不会退化,而用作strlen参数时就会退化成指针; 4、大部分编译器在编译期计算sizeof的值,所以其 阅读全文

posted @ 2018-03-21 00:09 lina2014 阅读(149) 评论(0) 推荐(0) 编辑

2018年3月20日

const和define的区别

摘要: C++中不但可以用define定义常量还可以用const定义常量,它们的区别如下: 1、编译器处理方式不同 define宏是在预处理阶段展开。 const常量是运行阶段使用。2、类型和安全检查不同 define宏没有类型,不做任何类型检查,仅仅是展开。 const常量有具体的类型,在编译阶段会执行类 阅读全文

posted @ 2018-03-20 11:30 lina2014 阅读(983) 评论(0) 推荐(0) 编辑

导航