- 博客(8)
- 收藏
- 关注
原创 位运算的巧用(或, 与,异或)
1. | 运算 任何一个数与0作或运算,它会得到它本身,与1作或运算,它会得到1。比如 所以,如果想把一个二进制数的第i位设为1,常可用 | 运算来实现。如下。 c |= ( 1 << i ); //把c的第i位设置为1 2. & 运算 任何一个数与1作与运算,它会得到它本身,与0作与运算,它会得到0。 所以,如果想把一个二进制数的第i位设为0,常可用 &运算来实现。如下。 c ...
2020-08-17 10:02:42
568
原创 Array VS Slice in golang
在如C/C++等语言中,对于函数参数的传递,有按值传递和按地址传递,golang中也有这样的使用方法。 我们想对数组的第一个元素作加一的操作。 1.按值传递。显然,如果我们使用的是按值传递,这将不会生效。 package main import "fmt" func foo(x [3]int){ x[0]++ } func main() { a := [3]int{1,2,3} foo(a) fmt.Print(a) } 输出结果: 2.按地址传递。 package ...
2020-08-03 11:12:40
155
原创 电商数据挖掘
import numpy as np import pandas as pd import matplotlib.pyplot as plt data = pd.read_excel('Online Retail.xlsx') data['InvoiceDate'] = pd.to_datetime(data['InvoiceDate']) data['Turnover'] = data['Un...
2020-02-16 09:27:34
1184
2
翻译 206. Reverse Linked List
Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL /*思路来源:点击打开链接 *//*迭代*/class Solution { public: ListNode* reverseList(ListN...
2018-06-17 13:30:38
168
原创 669. Trim a Binary Search Tree
Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might need to change the root of the tree, so the re...
2018-06-14 21:22:56
115
翻译 104. Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no children.Ex...
2018-06-13 10:59:05
116
翻译 101. Symmetric Tree
问题描述:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 Bu...
2018-06-12 23:00:42
128
原创 实作Binary Search Tree
/*实作一BSF,具有Insert, Delete两个主要函数*//*主要思路来源于台湾清华大学韩永楷老师的数据结构MOOC(其实就是听他讲后自己写的)*//*C语言代码实现*/#include <stdio.h>#include <stdlib.h>struct node{ int key; struct node *left, *right, *parent;};typ...
2018-06-06 15:35:58
166
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人