自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 【leetcode】二叉树后序遍历(stack)

145. Binary Tree Postorder Traversalleetcode题目题目描述Given a binary tree, return the postorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3

2018-01-03 14:41:39 363

原创 【leetcode】二叉树中序遍历(stack)

94. Binary Tree Inorder Traversalleetcode题目题目描述Given a binary tree, return the inorder traversal of its nodes’ values. For example: Given binary tree [1,null,2,3], 1 \ 2 / 3re

2018-01-03 14:09:36 528

原创 【leetcode】二叉树先序遍历(stack)

144. Binary Tree Preorder Traversalleetcode题目题目描述Pick OneGiven a binary tree, return the preorder traversal of its nodes’ values. For example: Given binary tree [1,null,2,3], 1 \ 2

2018-01-03 13:56:12 275

原创 【leetcode】Unique Paths II(动态规划)

63. Unique Paths IIleetcode题目题目描述Discuss Pick OneFollow up for “Unique Paths”: Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty spac

2018-01-03 13:16:54 291

原创 【leetcode】Unique Paths(动态规划)

62. Unique Pathsleetcode题目描述A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time.

2018-01-03 09:34:45 298

原创 【Algorithms】NP-complrte problem(exercises-8.14)

习题解答题目8.14 证明此问题是NP完全的:给定一个无向图G=(V,E)和一个整数k,求G中一个规模为k的团以及一个规模为k的独立集(假设存在)。

2018-01-03 08:48:22 205

原创 【Algorithms】NP-complete problems(exersises-8.8)

题目8.8在EXACT 4SAT问题中,输入为一组子句,每个子句都恰为4个literal的析取,且每个变量最多在每个子句中出现一次。目标是求其satisfying assignment(若其确实存在)。证明 EXACT 4SAT是NP完全问题。

2018-01-03 08:24:21 287

原创 【leetcode】回文串划分(DFS)

131. Palindrome Partitioningleetcode题目题目描述Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, gi

2017-12-13 08:05:21 256

原创 【leetcode】Reverse Integer(考虑溢出问题)

7. Reverse Integerleetcode题目题目描述Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123 Output: 321 Example 2:Input: -123 Output: -321 Example 3:Input: 120 Output: 21Note

2017-11-22 11:33:15 268

原创 【leetcode】Two Sum(unordered_map的使用)

1. Two Sumleetcode题目描述题目描述: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 y

2017-11-22 10:39:24 439

原创 【leetcode】最长连续序列(unordered_map的使用)

128. Longest Consecutive Sequenceleetcode题目描述题目描述: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 lo

2017-11-22 09:16:10 751

原创 【leetcode】搜索范围(二分查找升序数组target元素上下界)

34. Search for a Rangeleetcode题目描述题目描述:Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm’s runtime complexity must be

2017-11-01 09:46:06 791

原创 【leetcode】寻找两个已排序数组的中位数(类似二分)

4. Median of Two Sorted Arraysleetcode题目描述题目描述: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 shoul

2017-10-23 21:57:30 807

原创 【leetcode】有重复的旋转排序数组查找(二分)

81. Search in Rotated Sorted Array IIleetcode题目描述题目描述:Follow up for “Search in Rotated Sorted Array”: What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose

2017-09-28 13:34:29 592

原创 【leetcode】在旋转排序数组中查找(二分)

33. Search in Rotated Sorted Arrayleetcode题目描述题目描述:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are

2017-09-27 14:13:18 430

原创 【leetcode】查找插入位置(二分)

35. Search Insert Positionleetcode题目描述题目描述: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. Y

2017-09-20 10:31:17 818

原创 【leetcode】已排序数组去重 II

80. Remove Duplicates from Sorted Array IIleetcode题目描述题目描述:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra s

2017-09-12 21:44:02 1106

原创 【leetcode】已排序数组去重

【leetcode】已排序数组去重leetcode题目描述26. Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocat

2017-09-11 17:36:02 1362

原创 Pascal triangle (杨辉三角)制表符

Description: By using two-dimensional array, write C program to display a table that represents a Pascal triangle of any size. In Pascal triangle, the first and the second rows are set to 1. Each ele

2015-12-16 00:17:30 820

原创 合并字符串(动态内存申请)

Description: 合并两个字符串,每个字符串长度不小于1不超过50,主函数已经给出,在join.h头文件中完成join函数,函数原型如下:char* join(char* a, int alength, char* b, int blength)需要在join函数中动态申请内存,长度为a和b长度之和加1(因为字符串结尾有‘\0’); 函数返回值即所动态申请内存的首地址。输入:两个字符串,

2015-12-16 00:10:36 1157

原创 eggs(递归)

Description: Erin买了不少鸡蛋,她发现一天吃不完这么多,于是决定把n个同样的鸡蛋放在m个同样的篮子里,允许有的篮子空着不放,请问共有多少种不同的放法呢?注意:2,1,1和1,2,1 是同一种分法。Input 第一行是测试数据的数目t(0 <= t <= 20)。以下每行均包含二个整数m和n,以空格分开。1<=m,n<=10。Output 对输入的每组数据m和n,用一行输出相

2015-12-16 00:05:32 413

原创 Ant(GG)

Description: 一根长度为L厘米的木棒上有N只蚂蚁,每只蚂蚁要么向左走,要么向右走,速度为1厘米/秒。当两只蚂蚁相撞时,他们会同时掉头(掉头时间不计)给出每只蚂蚁距离木棒左端的距离,问多少秒后,刚好所有蚂蚁都从木棒上掉下来。N 和 L均不超过1000输入第一行两个整数,分别是N和L接下来N行,每行先是一个字符,L或R,代表向左还是向右,然后是一个整数x,代表这个蚂蚁距离木棒左端的距离。

2015-12-15 23:58:22 393

原创 挑战高楼(斐波那契非递归实现)

Description: Jeremy想要参加广州塔的垂直马拉松活动,然而Jeremy发现在爬楼梯的过程中有不同的方式:他可以一次走1级台阶,也可以一次走2级台阶。现在Jeremy准备在学校的楼梯进行练习准备,请问你可以算出他在m次爬n级台阶的时候,有多少种不同的方式吗?(利用函数进行计算,例如第n层的结果取决于第n-1和n-2层的结果)输入输出格式如下:input: mn1n2n3…nm (一

2015-12-09 15:09:38 427

原创 函数与递归练习

函数与递归最大公约数阶乘

2015-12-09 15:06:39 359

原创 Bucket sort 桶排序(含EOF)

桶排序;EOF

2015-12-09 14:14:02 333

转载 sicily 1007. To and Fro(破译密码)

Description: 题目大意:Mo and Larry have devised a way of encrypting messages. They first decide secretly on the number of columns and write the message (letters only) down the columns, padding with extra

2015-12-09 13:53:25 605

空空如也

空空如也

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

TA关注的人

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