- 博客(29)
- 资源 (2)
- 收藏
- 关注
原创 leetcode---Single Number---异或
Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra me
2016-09-29 21:52:38 394
原创 leetcode---Palindrome Partitioning---动规、回溯
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, given s = “aab”, Return[ [“aa”,”b”], [“a”,”
2016-09-28 21:57:47 291
翻译 Raft一致性算法
每个结点都只能是以下3种状态中的一种: 1、领导者 2、候选者 3、跟随者状态转换: 跟随者只能回应其它服务器的请求。如果一个跟随者收不到信息,则变为候选者,发起选举。一个候选者如果获得大多数选票,则成为新的领导者,直到它失效。Raft确保任何时期,都满足: 1、选举安全:给定时期内至多有一个领导者。 2、领导者从不重写或删除它的日志,它只增加新的日志。 3、日志匹配:如果两个日志
2016-09-28 18:26:51 440
原创 leetcode---Surrounded Regions---广搜
Given a 2D board containing ‘X’ and ‘O’ (the letter O), capture all regions surrounded by ‘X’.A region is captured by flipping all ‘O’s into ‘X’s in that surrounded region.For example, X X X X X O O
2016-09-27 14:15:46 304
原创 leetcode---Sum Root to Leaf Numbers---树的深度遍历
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total sum of al
2016-09-26 20:27:30 323
原创 leetcode---Best Time to Buy and Sell Stock II---贪心
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and
2016-09-25 20:02:29 314
原创 leetcode---Triangle---动规
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle The minimum path sum from top to
2016-09-24 18:15:20 303
原创 leetcode---Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example, Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: /** * Definition for a binary tree no
2016-09-24 17:29:32 690
原创 linux---磁盘与文件系统管理
查看/ /boot /home 三个目录所对应的inode:前2个为2,最后一个为390916 列出整体磁盘使用量 列出目录/etc容量 将可用inode数量列出 检查目录下每个目录所占容量,单位KB 查看系统内所有partition 系统有一颗盘,磁盘文件名为/dev/sda,容量为21.5G,分为sda1,sda2,sda3进入fdisk 查看分割表情况 删除
2016-09-24 17:26:31 514
原创 leetcode---Path Sum II---回溯
Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum.For example: Given the below binary tree and sum = 22, return [ [5,4,11,2],
2016-09-21 22:05:36 372
原创 leetcode---Convert Sorted List to Binary Search Tree---二叉搜索树
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNo
2016-09-20 20:38:23 615
原创 leetcode---Convert Sorted Array to Binary Search Tree---二叉搜索树
Given an array where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; *
2016-09-19 17:10:59 291
原创 Linux---文件与目录管理
切换目录 change directory 显示当前目录 print working directory 创建目录 make directory 创建权限为 rwx–x–x的目录 删除目录 remove directory 删除test以及test文件夹下所有内容 列出全部文件,包括隐藏文件 仅列出目录本身 列出长数据串,包括文件属性与权限等数据 连同子目录一
2016-09-18 09:44:23 350
原创 leetcode---Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree./** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right;
2016-09-17 18:16:26 333
原创 Linux---文件与目录权限
1、改变文件所属用户组:chgrp users install.log 将install.log用户组改为users,但users必须存在于/etc/group中才可以。2、改变文件所有者:chown bin install.log 将install.log所有者改为bin,但bin必须存在于/etc/passwd3、改变文件权限: 1)chmod 754 .bashrc
2016-09-17 16:44:48 319
原创 Linux---基本命令
列出所有“自己主文件夹(~)”下的“所有隐藏文件与相关的文件属性” 显示日期与时间 列出日历 计算器 命令补全:命令后面跟2个TAB 停止:Ctrl + C 退出:Ctrl + D 在线帮组:man 退出在线帮助:q 关机:shutdown -h now 现在关机; shutdown -h 20:10;20:10关机;shutdown -h +10 10分钟后挂机 重启:shu
2016-09-17 15:18:52 355
原创 leetcode---Construct Binary Tree from Preorder and Inorder Traversal---树的构建
Given preorder and inorder traversal of a tree, construct the binary tree./** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right;
2016-09-16 21:48:14 404
原创 leetcode---Binary Tree Zigzag Level Order Traversal---层次遍历
Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between).For example: Given binary tree
2016-09-14 22:27:16 366
原创 leetcode---Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node’s key. The right
2016-09-13 22:12:52 248
原创 leetcode---Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3./** * Definition for singly-lin
2016-09-12 21:32:48 209
原创 leetcode---Unique Binary Search Trees
Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example, Given n = 3, there are a total of 5 unique BST’s.1 3 3 2 1 \ /
2016-09-10 23:33:21 252
原创 leetcode---Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of the
2016-09-10 22:14:23 267
原创 leetcode---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 / 3 return [1,3,2]./** * Definition for a binary tre
2016-09-10 21:51:13 283
原创 保卫方案
#include "iostream"#include "vector"#include "string"#include "algorithm"using namespace std;int h[1000001];int main(){ int n; cin >> n; int i; for(i=0; i<n; i++) cin >> h[i
2016-09-06 20:31:08 430
原创 进制均值
#include "iostream"#include "vector"#include "string"#include "algorithm"using namespace std;int change(int n, int m){ int i = 0; int sum = 0; while(1) { sum += n % m;
2016-09-06 20:28:17 524 1
原创 餐馆---背包问题
#include "iostream"#include "vector"#include "string"#include "algorithm"using namespace std;struct People{ int n; int v; int index; bool operator < (const People &p) {
2016-09-06 20:26:09 587 2
原创 leetcode---Word Search---回溯
Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically neig
2016-09-06 17:39:14 306
原创 leetcode---Restore IP Addresses---回溯
Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example: Given “25525511135”,return [“255.255.11.135”, “255.255.111.35”]. (Order does not
2016-09-04 21:13:21 393
Rx_Net35_SP1
2019-03-13
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人