xixi2


  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

  • 搜索

164. Maximum Gap

发表于 2019-09-27 | 分类于 leetcode

Given an unsorted array, find the maximum difference between the successive elements in its sorted form.

Return 0 if the array contains less than 2 elements.

阅读全文 »

19. Remove Nth Node From End of List

发表于 2019-09-27 | 分类于 leetcode

Given a linked list, remove the n-th node from the end of list and return its head.

阅读全文 »

传参

发表于 2019-09-27 | 分类于 C++基础知识

传参有值传递和引用传递两种方式.
值传递用在参数较小的情况下,值传递过程中,形参和实参独立.对形参的修改不会影响实参.
引用传递用在:传递的参数较大或者不支持拷贝时.引用传递可以避免拷贝实参,但对形参的修改会直接影响实参.

阅读全文 »

sizeof

发表于 2019-09-27 | 分类于 C++基础知识
  • sizeof运算符返回一条表达式或一个类型所占的字节数.sizeof运算符的结果是一个size_t类型的值.

  • sizeof运算符满足右结合律.因此,表达式sizeof p等价于sizeof(\p). 这是因为sizeof满足右结合律且与*运算符的优先级相同.所以表达式会按照从右向左的顺序组合.

  • sizoef运算符并不实际求其运算对象的值.因此,sizeof运算可以对一个无效指针进行运算.

    阅读全文 »

二叉树的遍历的延伸

发表于 2019-09-27

中序遍历的延伸题

找出二叉搜索树中两个错误的节点

题目来源: leetcode
题目链接

Two elements of a binary search tree (BST) are swapped by mistake.

Recover the tree without changing its structure.

阅读全文 »

71. Simplify Path

发表于 2019-09-27 | 分类于 leetcode

题目描述

Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path.

In a UNIX-style file system, a period . refers to the current directory. Furthermore, a double period .. moves the directory up a level. For more information, see: Absolute path vs relative path in Linux/Unix

Note that the returned canonical path must always begin with a slash /, and there must be only a single slash / between two directory names. The last directory name (if it exists) must not end with a trailing /. Also, the canonical path must be the shortest string representing the absolute path.

阅读全文 »

225. Implement Stack using Queues

发表于 2019-09-27 | 分类于 leetcode

Implement the following operations of a stack using queues.

  • push(x) – Push element x onto stack.
  • pop() – Removes the element on top of the stack.
  • top() – Get the top element.
  • empty() – Return whether the stack is empty.
阅读全文 »

桶排序和计数排序

发表于 2019-09-27

比较排序,例如归并排序, 堆排序, 快速排序等等. 在比较排序中, 各元素的次序依赖于它们之间的比较.任何比较排序在最坏情况下都要经过O(nlogn)次比较.
快速排序的额外空间复杂度为O(logn),归并排序的空间复杂度为O(n),堆排序的空间复杂度为O(1)

阅读全文 »

动态内存

发表于 2019-09-27

静态内存用来保存局部静态对象,类静态数据成员以及定义在任何函数之外的变量.
栈内存用来保存定义在函数内的非static对象.
分配在静态或栈内存的对象由编译器自动创建和销毁.

阅读全文 »

Target Sum 系列

发表于 2019-09-27 | 分类于 leetcode

combination sum
Combination Sum II
Combination Sum III
Combination Sum IV

3Sum
4Sum
4Sum II

1…141516…18
xixi2

xixi2

一去不复返的远方还有无法抵达的过去

175 日志
21 分类
107 标签
© 2019 xixi2
由 Hexo 强力驱动
|
主题 — NexT.Mist v5.1.4
访问人数 总访问量 次