- 博客(22)
- 收藏
- 关注
原创 771. Jewels and Stones
You’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the sto...
2019-02-24 10:03:06
161
原创 网络编程-004-Raw-socket
Raw-socket 与 标准 socket 的区别 Raw-socket (原始套接字) 置于操作系统的网络核心 标准 socket 在 TCP 和 UDP 协议外围 Raw-socket 直接使用 IP 协议, 无连接 Raw-socket 实现的功能 发送自定义的 IP 包 发送 ICMP 包 进行网络嗅探, 捕获网络数据包 分析所有经过网络的数据报 伪装本地的IP地址 Ra...
2018-06-10 20:23:02
792
原创 网络编程-003-UDP-socket
UDP 协议的特点 UDP 不要求保持一个连接 UDP 没有因接收方检查数据包 (或当数据包没有正确抵达而自动重传) 而带来的开销 设计UDP的目的是用于短应用和控制消息 UDP要求的网络带宽比 TCP 更小 使用 UDP 协议的场合 传送的数据对顺序和可靠性要求不高 简单的 发送 — 接收 一次通信形式 传输的数据量较少 发送广播或多播信息 UDP 和 TCP 的区别 T...
2018-06-10 20:06:10
301
原创 网络编程-002-TCP-socket
TCP协议的工作流程 建立连接 通过三个报文段完成连接的建立, 该过程又称为三次握手 传输数据 数据流分割成适当长度的TCP报文段, 传递给IP层进一步处理后发出 给每个字节编一个序号, 确保不丢包, 接收端按顺序接收包 接收端对已成功收到的字节发回一个确认 (ACK), 如果发送端在往返时延 (RTT) 内未收到确认, 重传数据 关闭连接 当需要终止一个连接时, 要经过四次挥手 T...
2018-06-10 18:59:25
341
原创 网络编程-001-windows-socket
socket 概念 socket 中文译名套接字, 是网络通信的基本操作单元, 可以看做是不同主机之间进程进行双向通信的端点, 即通信双方的一种约定, 可用socket的相关函数来完成通信过程 socket是网络通信双方之间的纽带, 应用程序在网络上发送, 接受的信息都通过socket实现 socket可建立一次连接, 并对连接唯一标识 socket是操作系统的资源 socket 网络...
2018-06-09 19:11:19
1133
原创 网络编程-000-基础
网络编程的基本概念 网络编程是指利用网络编程接口编写网络应用程序,实现网络应用程序间的信息交互功能 网络编程接口是一种应用程序编程接口(API), 它包含一组通信例程或系统调用. 应用程序可以调用这些例程以便与位于相同或不同计算机上的其他应用程序通信 网络应用程序间的通信必须通过网络编程接口访问网络协议提供的服务来实现 网络编程的层次和种类 网络编程的层次 Web应用的网...
2018-06-09 15:11:13
308
原创 ruby selenium-webdriver
selenium-webdriver is a gem. Let’s see what it is. I install it by gem install selenium-webdriver and I need a browser driver brew cask install chromedriver irb # run Interactive Ruby ...
2018-06-07 20:49:06
407
原创 Exercise Of Modern Compiler Implementation in C
Write a function int maxargs(A_stm) that tells the maximum number of argument of any print statement within any subexpression of a given statement. For example, maxargs(prog) is 2. int bigger(int f...
2018-05-06 17:51:06
853
原创 747 Largest Number At Least Twice of Others
In a given integer array nums, there is always exactly one largest element. Find whether the largest element in the array is at least twice as much as every other number in the array. If it is, retu...
2018-04-21 00:11:53
196
原创 671 Second Minimum Node In a Binary Tree
Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node. If the node has two sub-nodes, then this node’s va...
2018-04-21 00:00:13
174
原创 458 Poor Pigs
There are 1000 buckets, one and only one of them contains poison, the rest are filled with water. They all look the same. If a pig drinks that poison it will die within 15 minutes. What is the minimum...
2018-04-20 23:47:37
164
原创 107 Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root). For example: Given binary tree [3,9,20,null,null,15,...
2018-04-20 20:21:22
155
原创 674 Longest Continuous Increasing Subsequence
Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray). Example 1: Input: [1,3,5,4,7] Output: 3 Explanation: The longest continuous increasing...
2018-04-20 19:33:37
153
原创 121 Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock),...
2018-04-20 19:27:20
183
原创 746 Min Cost Climbing Stairs
On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of ...
2018-04-20 18:56:59
152
原创 SICP Chapter1 Exercise
Exercise 1.1. Below is a sequence of expressions. What is the result printed by the interpreter in response to each expression? Assume that the sequence is to be evaluated in the order in which it is...
2018-04-20 18:23:54
228
原创 504 Base 7
Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: “202” Example 2: Input: -7 Output: “-10” Note: The input will be in range of [-1e7, 1e7]. class Solut...
2018-04-19 15:39:47
157
原创 541 Reverse String II
Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them...
2018-04-19 15:30:13
149
原创 744 Find Smallest Letter Greater Than Target
Given a list of sorted characters letters containing only lowercase letters, and given a target letter target, find the smallest element in the list that is larger than the given target. Letters also...
2018-04-19 14:55:55
160
原创 350 Intersection of Two Arrays II
Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each element in the result should appear as many times a...
2018-04-19 14:33:38
143
原创 108 Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the...
2018-04-19 14:04:58
167
原创 flex&bison_homework_1
1.1 Will the calculator accept a line that contains only a comment? Why not? Would it be easier to fix this in the scanner or in the parser? The program before will not accept a line that contains...
2018-03-25 17:23:58
450
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅