Leetcode 33. Search in Rotated Sorted Array

33.Search in Rotated Sorted Array You are given an integer array nums sorted in ascending order, and an integer target. Suppose that nums 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]). If target is found in the array return its index, otherwise, return -1. Example 1: Input: nums = [4,5,6,7,0,1,2], target = 0 Output: 4 Example 2: Input: nums = [4,5,6,7,0,1,2], target = 3

CSAPP Data Lab

CSAPP Data Lab Solution less or euqal than isLessOrEqual - if x <= y then return 1, else return 0 Example: isLessOrEqual(4,5) = 1. Legal ops: ! ~ & ^ | + << >> Max ops: 24 Rating: 3 判断一个数是否less or equal than 另一个数可以使用 -x + y 判断结果的符

IEEE 745 Floating-Point representation

IEEE 745 在IEEE745统一浮点数表示方法之前,不同的计算机采用了不同的浮点数表示方法。 Floating-Point representation The IEEE floating-point standard represents a number in a form $V = (−1)^s × M × 2^E$ 如图s为

Bitwise operations

Bitwise operations | OR & AND ^ XOR ~ Bitwise Complement: it makes every 0 to 1, and every 1 to 0. right shift >> left shift << e.g. x = 00111011; x >> 2; x = 00001110 -n = ~n + 1 Common use a^b^b = a 0^a = a^0 = a a^a = 0 N&(-N) merely keeps the rightmost 1 bit (equals N & (~N + 1)) N&(N

Leetcode 138 Copy List with Random Pointer

Description 138. Copy List with Random Pointer A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list. The Linked List is represented in the input/output as a list of n nodes. Each node is represented as a pair of [val, random_index] where: val: an integer representing Node.val random_index:

Leetcode 142 Linked List Cycle II

Description 142. Linked List Cycle II Given a linked list, return the node where the cycle begins. If there is no cycle, return null. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail’s next pointer is connected to. Note