自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Two Sum II

÷Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers...

2018-07-31 10:46:34 187

原创 LeetCode Kth Smallest Element in a Sorted Matrix378

Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.Note that it is the kth smallest element in the sorted order, not t...

2018-07-29 19:38:38 215

原创 LeetCode First Bad Version278

You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the...

2018-07-29 16:02:21 223

原创 LeetCode Contains Duplicate217

Given an array of integers, find if the array contains any duplicates.Your function should return true if any value appears at least twice in the array, and it should return false if every element i...

2018-07-29 15:23:24 162

原创 LeetCode Merge Sorted Array 88

Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assu...

2018-07-29 14:43:25 177

原创 LeetCode Merge Two Sorted Lists21

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Output: 1-...

2018-07-29 13:26:07 124

原创 LeetCode count and say 38

count-and-say序列是整数序列,前五个术语如下:1. 12. 113. 214. 12115. 1112211作为"one 1"或读出11。11作为"two 1s"或读出21。21被读出"one 2,然后one 1"或1211。给定整数n,生成count-and-say序列的第n项。注意:整数序列的每个术语将表示为一个字符串。例1:输入: 1 输出:...

2018-07-29 12:36:47 129

原创 数据结构 排序 基数排序

#include <stdio.h>#include <stdlib.h>#include <string.h>#define lowbit(x) (x & 0xffff)#define highbit(x) ((x >> 16) & 0xffff)#define swap(a,b){ \ __typeof(a) _...

2018-07-28 12:15:51 126

原创 LeetCode 二叉树路径257

Given a binary tree, return all root-to-leaf paths.Note: A leaf is a node with no children.Example:Input:​   1 /   \2     3 \ 5​Output: ["1->2->5", "1->3"]​Explanation: All ...

2018-07-25 18:01:09 245

原创 LeetCode 路径总和112

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note: A leaf is a node with no children.Example:...

2018-07-25 11:01:51 297

原创 LeetCode 平衡二叉树 110

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the depth of the two subtrees of every node never diff...

2018-07-25 10:05:39 168

原创 LeetCode 二进制搜索树的最低共同祖先235

Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between ...

2018-07-24 17:25:33 320

原创 LeetCode 二叉树的最小深度 111

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.Note: A leaf is a node with no childre...

2018-07-24 16:46:18 170

原创 LeetCode 反转二叉树 226

Invert a binary tree.Example:Input:     4   /   \ 2     7 / \   / \1   3 6   9Output:     4   /   \ 7     2 / \   / \9   6 3   1思路1.如果树的根为空,直接返回NULL即可;2.当根的左子树或者右子树存在的时候,将左...

2018-07-24 16:29:06 153

原创 LeetCode 树的最大深度104

Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no childre...

2018-07-23 15:04:33 168

原创 LeetCode 对称树 101

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3B...

2018-07-23 10:47:59 191

原创 LeetCode 相同的树100

Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.Example ...

2018-07-23 09:29:56 234

原创 LeetCode 搜索插入位置 35

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 array....

2018-07-22 20:06:15 184

原创 LeetCode 两个排序数组的中位数4

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 should be O(log (m+n)).Example 1:nums1 = [1, 3...

2018-07-22 20:04:24 159

原创 c语言 杂记

1.从右往左读 碰到*读指向 碰到const读常量​ int const *x;const int *x;x指向整型常量 常量指针​ int *const x; x常量指向整型 指针常量2.浮点型判断abs(x - 1.0) < epson,不然会无限循环3.科学计数法:前面的数可以是整型或者浮点型 中间是E/e 后面的数字必须是整型4.数值在c语言中只有三种表示形式 十...

2018-07-21 10:50:34 645

原创 LeetCode 有效的括号

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if: Open brackets must be closed by the same type of...

2018-07-20 16:05:35 216

原创 LeetCode 两数之和(无序版)

Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same ...

2018-07-19 09:42:09 209

原创 LeetCode 两书之和(无序版)

Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same ...

2018-07-19 09:18:10 214

原创 LeetCode 没有重复字符的最长子串

Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "b", with...

2018-07-18 14:37:27 152

原创 LeetCode两数之和(有序版)

Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers su...

2018-07-18 13:03:32 189

原创 数据结构 查找 哈希表

哈希:从高维空间【信息量更大的空间】到低维空间【所能容纳信息量较少的空间】的映射(会发生冲突)冲突处理方法:4种结构定义:size:数组大小data_type:任意类型映射到整型提供数组下标找值时间复杂度O(1)#include <stdio.h>#include <stdlib.h>#include <string.h>t...

2018-07-17 14:14:36 135

原创 数据结构 查找 二分查找与三分查找

有序条件下,才能查找一.二分查找(具有单调性,不一定严格单调)(min 与max 是查找区间,通过不断缩小查找区间,来查找x的值)min是头指针; max是尾指针;mid = (min + max) / 2;终止条件:min >= max如果arr[mid] < x, min = mid + 1;如果arr[mid] > x, max = mid - ...

2018-07-17 10:14:33 2063

原创 数据结构 排序 不稳定排序

非稳定排序:选择排序、快速排序如果有两个数字的数值大小相同,排序后的相对顺序为被改变。一.选择排序1.将数组分成【已排序区】和【待排序区】2.每一轮从【待排序区】中选择一个最小的元素放到【已排序区】的尾部3.直到【待排序区】没有元素为止二.快速排序快速排序和归并排序的区别:快:【先处理当前的大问题 再分治】归:【先分治再递归】坏时间复杂度:n^2好时间复杂度:n...

2018-07-16 18:49:01 687

原创 数据结构 排序 稳定排序

稳定排序:插入排序、冒泡排序、归并排序如果有两个数字的数值大小相同,排序后的相对顺序为被改变。一.插入排序时间复杂度:n^21.将数组分成【已排序区】和【待排序区】2.将【已排序区】后面一个元素,向前插入到【待排序区】中3.直到【待排序区】没有元素为止二.冒泡排序(非随机存储的排序)时间复杂度:n^2将数组分成【已排序区】和【待排序区】2.从头到尾扫面【待排...

2018-07-16 16:39:28 940

原创 数据结构 堆与优先队列

完全二叉树除了最后一层,其余层都是满二叉树;最后一层只能是右侧缺失1.编号为i的子结点:左孩子编号2i;右孩子编号2 * i + 1(从1开始编号) ***[方便] 编号为i的子结点:左孩子编号2i + 1;右孩子编号2 * i + 2(从0开始编号)2.可用连续空间存储(数组),由于编号连续[通过计算得到孩子结点的编号,节省存储空间];堆大顶堆:二叉树中每三个单元看作一个元素,父结点的值永远大...

2018-07-15 18:16:16 108

原创 数据结构 树与二叉树

一.树结点的数量=边数+1;二.二叉树1.每个结点的度最多为22.度为0的结点比度为2的结点多1个 结点的个数 = 边的个数 + 1; N0 + N1 + N2 = N1 + 2 * N2 + 1; N0 = N2 + 1;3.前序遍历 根 左 右中序遍历 左 根 右后序遍历 左 右 根(逆波兰表达式容易计算)4.删除度为2的结点转化为删除度为0的结点;#include <stdio.h&g...

2018-07-14 15:42:54 249

原创 数据结构 栈与队列

一.队列FIFO操作系统是分时系统,分时系统有队列,给进程排队(优先队列)先入先出适合处理具有先后顺序的问题; 【循环队列】树的层序遍历 广度优先搜索 【单调队列】区间的最大(小)值队列的结构定义:需要连续的存储区,任意类型的指针(内建类型int ,float,其他类型:struct,里面也可以存放链表)head:队列头指针;tail:位置不是固定的,可以指向第一个为空...

2018-07-14 12:28:15 189

原创 数据结构 顺序表与链表

数据元素是数据的基本单位 数据元素不能再分 原子项 数据元素可以再分 组合项若干数据项组成一个数据元素数据项是数据的最小单位算法 :有穷性 确切性 输入项 输出项 可行性时间复杂度 : O(1) O(logn) O(n) O(nlogn)O(n2)O(n3)O(2n)O(n!)线性表中所有元素的数据类型都是相同的一:综述程序 = 算法 + 数据结构数据结构 = 结构定义 + 结构操作*1.顺序...

2018-07-13 17:22:35 326

原创 欧拉计划 第二十三题

A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means th...

2018-07-13 10:08:21 340

原创 欧拉计划 第二十一题

Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are...

2018-07-13 09:36:06 299

原创 欧拉计划 第十九题

You are given the following information, but you may prefer to do some research for yourself.1 Jan 1900 was a Monday.Thirty days has September,April, June and November.All the rest have thirty-one,Sav...

2018-07-11 19:20:12 330

原创 欧拉计划 第四十七题

The first two consecutive numbers to have two distinct prime factors are:14 = 2 × 715 = 3 × 5The first three consecutive numbers to have three distinct prime factors are:644 = 2² × 7 × 23645 = 3 × 5 ×...

2018-07-11 19:02:34 300

原创 欧拉计划 第四十六题

prime and twice a square.9 = 7 + 2×1215 = 7 + 2×2221 = 3 + 2×3225 = 7 + 2×3227 = 19 + 2×2233 = 31 + 2×12It turns out that the conjecture was false.What is the smallest odd composite that cannot be wri...

2018-07-11 18:33:08 226

原创 欧拉计划 第三十九题

If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.{20,48,52}, {24,45,51}, {30,40,50}For which value of p ≤ 1000, is the...

2018-07-11 16:09:51 236

原创 HTTP Web的攻击技术

一.针对Web的攻击技术1.HTTP不具备必要的安全功能2.在客户端可篡改请求主动攻击:SQL注入攻击、OS注入攻击攻击者通过直接访问Web应用,把攻击代码传入攻击模式。主要攻击服务器上的资源被动攻击:跨站脚本攻击、HTTP首部注入攻击、邮件注入攻击、会话固定攻击、跨站点请求伪造利用圈套策略执行代码的攻击模式。在被动攻击过程中,攻击者不直接对目标Web应用访问发起攻击。(1)攻击者诱导用户触发已设...

2018-07-11 14:34:55 940

空空如也

空空如也

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

TA关注的人

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