自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(29)
  • 收藏
  • 关注

原创 2. 两数相加

题目:给出两个非空的链表用来表示两个非负的整数。其中,它们各自的位数是按照逆序的方式存储的,并且它们的每个节点只能存储一位数字。如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。您可以假设除了数字 0 之外,这两个数都不会以 0开头。示例:输入:(2 -> 4 -> 3) + (5 -> 6 -> 4)输出:7 -> 0 -> 8原因:342 + 465 = 807来源:力扣(LeetCode)链接:https://lee.

2020-05-22 00:05:38 166

原创 c++ 链表 new 与malloc 的区别

一、struct中含有默认构造函数struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};

2020-05-21 19:36:44 1089 1

原创 优雅的点(2017网易校招)--python版本

题目分析见我的c++版本:https://blog.csdn.net/newandbetter/article/details/80341512import mathz = float(input())r = math.sqrt(z)count = 0if(r == int(r)):    count = count + 4    print('(',int(0),',',int(r),')') ...

2018-05-16 20:45:55 378

原创 优雅的点(2017网易校园招聘)---最详细的解答

时间限制:1秒空间限制:32768K热度指数:68102算法知识视频讲解题目描述小易有一个圆心在坐标原点的圆,小易知道圆的半径的平方。小易认为在圆上的点而且横纵坐标都是整数的点是优雅的,小易现在想寻找一个算法计算出优雅的点的个数,请你来帮帮他。例如:半径的平方如果为25优雅的点就有:(+/-3, +/-4), (+/-4, +/-3), (0, +/-5) (+/-5, 0),一共12个点。输入描...

2018-05-16 20:05:01 225

翻译 c++格式化输出-------#include<iomanip>

io代表输入输出,manip是manipulator(操纵器)的缩写-------来自于百度百科具体函数:1.setiosflags  /*unspecified*/ setiosflags (ios_base::fmtflags mask);    setiosflags的参数是该流的格式标志值,这个值由如下位掩码(ios枚举器)指定,并可用位或OR(|)运算符进行组合:    ios::ski...

2018-05-16 15:33:16 534

原创 cstring常用函数

cstring笔记1.puts输出字符数组串,char*s,char s[];注意初始化时要尽可能大的空间2.复制: memcpy ( &person_copy, &person, sizeof(person) ); printf ("person_copy: %s, %d \n", person_copy.name, person_copy.age );  memcpy注意只能用...

2018-05-11 20:29:21 3310

原创 细谈字符串:字符数组,string

C++中处理字符串的两种方法:1.字符数组,如:    char str[10];    初始化的方法:    char str[10] = {'h','e','l','l','o'};// char str[10] = "hello"; 这样是错误的做法    或者    char str[10];    for(int i = 0; i < 10; i++)    {   char t;...

2018-05-10 23:22:57 230

原创 某一个输入的位数不确定的正整数按照标准的三位分节格式输出

题目描述:编写程序,将某一个输入的位数不确定的正整数按照标准的三位分节格式输出,例如,当用户输入82668634时,程序应该输出82,668,634。编程,一个良好的思维极其重要。首先分析输入:输入是一个多位数(int型)输出分析:82,668,634为一个字符串思考:如何处理这个多位数?怎么样处理才能使用里面的数字。这时候对于十进制的多位数往往是采用除以10取余数,一位一位的提取出来。例如:12...

2018-05-02 20:24:07 11636 3

原创 详谈指针

指针是c语言的特色之一,c++沿用了这一特色,并将其进行扩充。指针在c++中有着举足轻重的地位,真正弄清楚c++的指针对于每一个c++学习者来说是非常重要的一件事。一、首先,什么是指针?指针是一种就是变量的地址。什么是指针变量?指针变量就是一种特殊的变量,同其他的变量一样,必须在定义语句进行定义,亦可以在定义的同时进行指针变量的初始化。二、指针变量的一般形式:数据类型 * 指针变量名其中“*”表示...

2018-05-02 16:57:56 177

原创 细数参数:形参,实参

一、首先明确什么是形参,什么是实参实参,顾名思义,实际参数,可以理解为有具体数值的参数形参,顾名思义,形式参数,可以理解为无具体数值的参数比如:void swap(int a,int b)//a和b就是形参,因为这里的a和b并没有具体的值int x =1;int y = 2;swap(x,y);//这里的x,y就是实参,他们有具体的数值二、讲一下“引用”:引用是c++对c的一个扩充。变量的“引用”...

2018-05-02 10:44:05 730

原创 C++自我再提升0(自序)

C++已经学习了近三年了,当初的学习只是应付考试,现在我要重新拾起来,很期待之后更多的感悟。都说熟悉一门语言很容易,但是精通一门语言很难。所以对于我来说,自己c++语言能力的提升是无止境的!加油,要做一个技术男!...

2018-05-01 22:43:43 168

原创 2017算法课.作业(8.19)

题目:A ktie is a graph on even number of vertices, say 2n, in which n of the vertices form a clique and the remaining n vectors are connected in a tail that consisits of a path joined to one of th

2017-07-11 03:29:00 222

原创 2017算法课.17(Binary Tree Inorder Traversal)

Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3],   1    \     2    /   3return [1,3,2].根据中序遍历的顺序

2017-06-17 12:08:31 171

原创 2017算法课.16(Predict the Winner)

Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a player picks a

2017-06-11 22:10:54 266

原创 2017算法课.15(Friend Circle)

There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then

2017-06-03 17:19:17 1172

原创 2017算法课.14(Course Schedule)

There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair

2017-05-27 11:33:38 252

原创 2017算法课.13(Binary Tree Preoder Traversal)

题目:Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3},   1    \     2    /   3return [1,2,3].解析:众所周知,二叉树的

2017-05-20 17:10:14 430

原创 2017算法课.12(Binary Tree Tilt)

Given a binary tree, return the tilt of the whole tree.The tilt of a tree node is defined as the absolute difference between the sum of all left subtree node values and the sum of all right subt

2017-05-14 08:40:41 223

原创 2017算法课.11(3Sum Closest)

问题:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would hav

2017-05-06 18:16:59 224

原创 2017算法课.10(Find All Numbers Disappeared in an Array)

Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.

2017-04-28 22:54:12 152

原创 2017算法课.09(Is Subsequence)

Given a string s and a string t, check if s is subsequence of t. You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string

2017-04-22 22:33:25 196

原创 2017算法课.08(Assign Cookies )

455. Assign CookiesAdd to ListFavoriteCreate a New ListOpen My ListDescriptionHintsSubmissionsSolutionsTotal Accepted: 21109Total Submissions: 44746Diffic

2017-04-15 12:28:42 183

原创 2017算法课.07(Detect Capital)

520. Detect Capital Add to ListFavoriteCreate a New ListOpen My ListDescriptionSubmissionsSolutionsTotal Accepted: 16777Total Submissions: 31953Di

2017-04-08 23:14:43 192

原创 2017算法课.05(Search Insert Position )

题目:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the arr

2017-03-26 13:19:00 142

原创 2017算法课.04(Valid Anagram )

Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false. Note:You may assu

2017-03-19 00:35:04 194

原创 2017算法课.03(Decode String)

题目: Given an encoded string, return it'sdecoded string. The encoding rule is: k[encoded_string],where the encoded_string inside the square brackets is being repeated exactly ktimes.

2017-03-12 00:23:54 286

原创 2017算法课.02(majority element)

这道题目,前提条件已经说明了,nums数组必然存在这么一个数,他的元素个数要大于数组中所有元素数目的一半。所以,这里就不必考虑是否不存在的情况。例如:假定一组数是 2 3  6  2 3 2 2此时2的数目4个,大于整个数组所有元素数目7个。所以输出的结果应该是2.最简单的方法当然就是暴力解法:先访问一遍所有的元素,并将元素储存在新的对象数组里面。创建一个结构体

2017-03-04 19:24:23 345

原创 2017算法课.01(Next Greater Element I)

本学期第二个简单代码练手!Next Greater Element 1第一步:理解题意        1.向量findNums是nums的子集        2.向量findNums中的每个元素都对应nums的元素,并找到对应的位置。        3.对于nums中对应的元素,如果该元素之后又比该元素大的数,就把该数放到临时向量中去。若不然,把-1放到临时向量中去。

2017-02-24 20:33:54 354 1

原创 2017算法课.00_(missingNumber)

2017新的开始!学期,新期望,真心希望这学期能够在林老师的指导下,写代码的能力能够得到很大的提升!我会充分利用leetcode提供的大量资源,我会尽力去打更多的代码,争取早日跻身代码高手的行列中去!加油!作为代码技术“半度残废“”的新手,选择了一个简单的题目(The missingNumber)开启我的全新学期!这道题目在c++.课堂上曾经做过,现在利用数组将其解决!

2017-02-23 15:16:05 226

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除