- 博客(25)
- 收藏
- 关注
原创 98. 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 keysless thanthe node's key. The ...
2020-01-31 19:51:37 444
原创 《黑客与画家》读书笔记(四)
1. 摘录 机器语言 机器语言和汇编语言的共同问题就是,只能让大多数计算机做一些很简单的事情。编程语言的一个重要特点:代码越多,越难避免bug,也越难发现bug。 高级语言 高级语言使程序更简短,更具有可移植性。高级语言的实现方法有编译器和解释器,编译器是先将整个程序全部翻译成机器语言,然后再运行。解释器的作用是实时地将代码解释为相应的机器语言,然后一行行运...
2020-01-31 17:38:58 4498
原创 242. Valid Anagram
Given two stringssandt, write a function to determine iftis an anagram ofs.Example 1:Input: s = "anagram", t = "nagaram"Output: trueExample 2:Input: s = "rat", t = "car"Output: fal...
2020-01-31 14:41:28 446
原创 338. Counting Bits
Given a non negative integer numbernum. For every numbersiin the range0 ≤ i ≤ numcalculate the number of 1's in their binary representation and return them as an array.Example 1:Input: 2Out...
2020-01-31 13:05:07 1569
原创 231. Power of Two
Given an integer, write a function to determine if it is a power of two.Example 1:Input: 1Output: true Explanation: 20= 1Example 2:Input: 16Output: trueExplanation: 24= 16Example 3:...
2020-01-31 12:38:17 406
原创 191. Number of 1 Bits
Write a function that takes an unsigned integer and returnthe number of '1'bits it has (also known as theHamming weight).Example 1:Input: 00000000000000000000000000001011Output: 3Explanation...
2020-01-31 11:59:35 332
原创 《黑客与画家》读书笔记(三)
1. 摘录 致富最好的办法就是创业,创业就像是一个压缩过程,它将几十年的工作压缩到几年,如此高强度的工作,所带来的回报也是丰厚的。 金钱不等于财富 金钱只是财富的一种简便表达方式,它是交换的媒介。大多数生意的目的是为了创造财富,做出人们真正需要的东西。 大饼谬论 “世界上的财富总额是固定不变的”这样的观点是错误的。持有这些观点的人是混淆了“金钱”与...
2020-01-31 10:18:42 1954
原创 《黑客与画家》读书笔记(二)
1. 良好的坏习惯 为什么”版权”是黑客们的讨论热点? 在黑客看来,增大“版权”保护力度,会束缚工作自由。 深入了解当前技术,黑客们才能构想下一代的技术。 版权法禁止了外部人员了解技术的内部细节,为新技术的产生设置了障碍。 为什么“公民自由”受到黑客的广泛关注? 自由是国家富强的前提,一个言论和行动自由的社会,才最有可能采纳最优方案,而不...
2020-01-31 09:44:51 649
原创 《黑客与画家》读书笔记(一)
摘录 1. 任何一种艺术,不管是否重要,如果你想要在该领域出类拔萃,就必须全身心投入。 2. 为什么聪明的小孩没有让自己变得受欢迎?如果他们真的很聪明,为什么找不到受欢迎的诀窍呢?他们在标准化测试中表现得这么好,为什么就不能在这方面也大获成功呢?我认为,答案就是他们真的不想让自己受欢迎。他们更想追求的是另一件事情——聪明。这不仅仅意味着在学校得到好成绩(虽然某种程度上这也挺重要...
2020-01-30 21:55:14 2252
原创 Youtube内容正在失控
本文介绍《经济学人》上 的一篇文章(YouTube's Top 10, the Most-Moneyed Digital Superstars, Feb 2019),主要分析Youtube正在面临内容失控的困局。1.内容失控的原因海量用户自制内容 Youtube最为全球最大的用户自创内容平台,无论是音乐、游戏、时尚,还是新闻、教育、科学等等应有尽有。 目前平台上...
2020-01-30 19:28:25 651
原创 547. Friend Circles
There areNstudents in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is adirectfriend of B, and B is adirectfriend of C, then ...
2020-01-21 14:18:09 354
原创 200. Number of Islands
Given a 2d grid map of'1's (land) and'0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume...
2020-01-21 14:15:17 324
原创 703. Kth Largest Element in a Stream
Design a class to findthekth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.YourKthLargestclass will have a constructor wh...
2020-01-21 10:22:15 422
原创 206. Reverse Linked List
Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLFollow up:A linked list can be reversed either iteratively or recursi...
2020-01-19 21:41:48 350
原创 24. Swap Nodes in Pairs
Given alinked list, swap every two adjacent nodes and return its head.You maynotmodify the values in the list's nodes, only nodes itself may be changed.Example:Given 1->2->3->4, you...
2020-01-19 21:41:34 236
原创 141. Linked List Cycle
Given a linked list, determine if it has a cycle in it.To represent a cycle in the given linked list, we use an integerposwhich represents the position (0-indexed)in the linked list where tail co...
2020-01-19 21:41:34 262
原创 50. Pow(x, n)
Implementpow(x,n), which calculatesxraised to the powern(xn).Example 1:Input: 2.00000, 10Output: 1024.00000Example 2:Input: 2.10000, 3Output: 9.26100Example 3:Input: 2.00000, ...
2020-01-19 21:41:19 240
原创 20. Valid Parentheses
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 b...
2020-01-19 21:41:04 312
原创 69. Sqrt(x)
Implementint sqrt(int x).Compute and return the square root ofx, wherexis guaranteed to be a non-negative integer.Since the return typeis an integer, the decimal digits are truncated and only...
2020-01-19 21:40:59 338
原创 ReadDirectoryChangesW 监控文件变化
本文测试了ReadDirectoryChangesW类监控文件变化。#include<iostream> #include<string>#include<Windows.h>using namespace std;string WStringToString(const std::wstring &wstr);void R...
2020-01-15 18:00:40 1291 2
原创 FileSystemWatcher 监控文件变化
本文测试了FileSystemWatcher 类监控文件变化。using System;using System.Security.Permissions;using System.IO;namespace ConsoleApp1{ public class FileStateWatcher { [PermissionSet(Secu...
2020-01-15 15:44:32 1233
原创 c++实现简单的线程池
线程池,先创建一定数目的线程,初始都处于空闲状态。当有新的任务进来,从线程池中取出一个空闲的线程处理任务,处理完成之后,该线程被重新放回到线程池中。当线程池中的线程都在处理任务时,若有新的任务产生,只能等待,直到线程池中有线程结束任务空闲才能执行。 用c++实现固定线程数的线程池。#include <mutex>#include <condition_va...
2020-01-14 16:54:41 881
原创 删数
题目:有一个数组a[N]顺序存放0~N-1,要求每隔两个数删掉一个数,到末尾时循环至开头继续进行,求最后一个被删掉的数的原始下标位置。以8个数(N=7)为例:{0,1,2,3,4,5,6,7},0->1->2(删除)->3->4->5(删除)->6->7->0(删除),如此循环直到最后一个数被删除。 解法:用队列模拟,队首取数,用一...
2020-01-14 08:58:10 318
原创 物理CPU数、CPU核心数、CPU线程数
Windows系统中,在cmd中输入命令“wmic”。>wmicwmic:root\cli> 输入命令“cpu get Name”,获取物理CPU数。wmic:root\cli>cpu get NumberOfCoresNumberOfCores6 输入命令“cpu get NumberOfCores”,获取CPU核心数。wm...
2020-01-13 10:50:24 1980
原创 数据库批量插入数据
为了提高数据库的效率,采用批量插入的方式。1.InsertEntitybool DbWriter::InsertEntity(const std::vector<std::shared_ptr<IDbTable>>& entities){ if (entities.size() == 0) return true; ...
2020-01-07 15:14:20 705
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人