- 博客(12)
- 收藏
- 关注
原创 简单错误记录
开发一个简单错误记录功能小模块,能够记录出错的代码所在的文件名称和行号。 处理:1.记录最多8条错误记录,对相同的错误记录(即文件名称和行号完全匹配)只记录一条,错误计数增加;(文件所在的目录不同,文件名和行号相同也要合并)2.超过16个字符的文件名称,只记录文件的最后有效16个字符;(如果文件名不同,而只是文件名的后16个字符和行号相同,也不要合并)3.输入的文件可能带路径,记录
2017-04-01 14:17:58 333
原创 leedcode word break
Given a string s and a dictionary of words dict, determine ifs can be segmented into a space-separated sequence of one or more dictionary words.For example, givens ="leetcode",dict =["leet", "
2017-03-21 11:49:55 263
原创 【LeetCode】Candy
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least
2017-03-19 18:04:20 195
原创 [leetcode] 134. Gas Station
There are N gas stations along a circular route, where the amount of gas at stationi isgas[i]. You have a car with an unlimited gas tank and it costscost[i]of gas to travel from stationi to its
2017-03-19 16:00:05 194
原创 在4x4的棋盘上摆满了黑白棋子,黑白两色的位置和数目随机其中左上角坐标为(1,1),右下角坐标为(4,4),现在依次有一些翻转操作,要对一些给定支点坐标为中心的上下左右四个棋子的颜色进行翻转,请计算出
在4x4的棋盘上摆满了黑白棋子,黑白两色的位置和数目随机其中左上角坐标为(1,1),右下角坐标为(4,4),现在依次有一些翻转操作,要对一些给定支点坐标为中心的上下左右四个棋子的颜色进行翻转,请计算出翻转后的棋盘颜色。给定两个数组A和f,分别为初始棋盘和翻转位置。其中翻转位置共有3个。请返回翻转后的棋盘。测试样例:[[0,0,1,1],[1,0,1,0],[0,1,1,0],[0,0,
2017-03-18 23:33:13 4496
原创 有一个长为n的数组A,求满足0≤a≤b<n的A[b]-A[a]的最大值。 给定数组A及它的大小n,请返回最大差值。 测试样例: [10,5],2 返回:0
算法思想:遍历一遍数组,每次遍历判断最小值,并计算是否是最大距离class LongestDistance {public: int getDis(vector A, int n) { // write code here int minValue = A[0]; int max = 0; for(int
2017-03-18 22:53:09 3700 1
转载 柔性数组
柔性数组(Flexible Array)也叫伸缩性数组,其实就是变长数组,反映了C语言对精炼代码的极致追求。这种代码结构产生于对动态结构体的需求。比如我们需要在结构体中存放一个动态长度的字符串,这时候,柔性数组可以大显身手了
2017-03-17 19:28:49 270
转载 最短路径—Dijkstra算法和Floyd算法
Dijkstra算法1.定义概览Dijkstra(迪杰斯特拉)算法是典型的单源最短路径算法,用于计算一个节点到其他所有节点的最短路径。主要特点是以起始点为中心向外层层扩展,直到扩展到终点为止。Dijkstra算法是很有代表性的最短路径算法,在很多专业课程中都作为基本内容有详细的介绍,如数据结构,图论,运筹学等等。注意该算法要求图中不存在负权边。问题描述:在无向图 G=(V,E) 中,假
2017-03-17 18:52:55 260
原创 Given a binary tree, return the preorder traversal of its nodes' values.
vector tree::preorderTree(treeNode *root){ vector result; stack tempStack; treeNode *dummyRootNode = root;//不知道root值是否会被改变 所以用这种方式 要测试一下 if(dummyRootNode) tempStack.push
2017-03-17 14:27:14 796
原创 Given a binary tree, return the postorder traversal of its nodes' values.
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */cla
2017-03-17 14:21:42 435
原创 Sort a linked list using insertion sort
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *//*void insertionSort(int *a,int
2017-03-17 01:45:25 257
原创 Sort a linked list in O(n log n) time using constant space complexity.
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public:
2017-03-17 00:14:50 248
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人