2014年4月7日

【LeetCode练习题】Merge Sorted Array

摘要: Merge Sorted ArrayGiven two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal tom+n) to hold additional elements from B. The number of elements initialized in A and B aremandnrespectively.题目意思:将两个有序的数组合并成一个有序的 阅读全文

posted @ 2014-04-07 23:37 Allen Blue 阅读(161) 评论(0) 推荐(0) 编辑

【LeetCode练习题】Reverse Linked List II

摘要: Reverse Linked List IIReverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.Note:Givenm,nsatisfy the following condition:1 ≤m≤n≤ length of list.题目意思:翻转给定区间[m,n]的链表。第一个节点m=1。 1n 阅读全文

posted @ 2014-04-07 22:51 Allen Blue 阅读(2336) 评论(0) 推荐(0) 编辑

【C++】大数的+-*/四则运算

摘要: 所谓大数,则指数值特别大的数,可能会有99位,100位,远远超过了long long表示的范围。这样的数作四则运算,需要用到字符串。用字符串通过每一位的字符的四则运算来模拟。废话少说,上代码: 1 #include 2 #include 3 using namespace std; 4 5 class BigNum{ 6 vector m_vec; 7 //构造函数,析构函数,size()函数,友元重载>>,>(istream &is,BigNum &data); 23 24 public: 25 char operator[](int nInde... 阅读全文

posted @ 2014-04-07 16:50 Allen Blue 阅读(686) 评论(0) 推荐(0) 编辑

【LeetCode练习题】Multiply Strings

摘要: Multiply StringsGiven two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.题目意思:给两个string,计算string的乘积。string中的数可以非常大并且是非负数。(就是大数的乘法运算嘛。。。)解题思路:由于之前已经练习过了大数的加减乘除四则运算了,所以这道题跟那个是一样的原理。要想实现乘法,首先得实现大数的加法,因为按照小 阅读全文

posted @ 2014-04-07 16:46 Allen Blue 阅读(201) 评论(0) 推荐(0) 编辑

导航