- 博客(50)
- 问答 (2)
- 收藏
- 关注
原创 【数据库】Mac环境解决MySQL不能插入中文的问题
看了好多教程,终于搞好了。 参考: https://blog.youkuaiyun.com/vr_jia/article/details/71891515 http://www.cnblogs.com/mojita/p/5347614.html 1. 到/etc目录下,用sudo最高权限,创建一个my.cnf文件,并输入:[client]default-character-set=utf8...
2018-05-02 20:52:05
1044
原创 拿到了摩根斯坦利IT部门offer(2018 Morgan Stanley Technology Summer Analyst)
这次校招我技术产品混投了,大摩投了Technology技术部门。最后结果看来,我又能做产品又能做技术哈哈!从笔试到电话面试再到AC面,第一次全程英文面试的体验,宝贵的经历,决定记录下来。笔试IKM试题,没什么好说的,必考,可以看看往年的笔试题,差别不会很大,最重要的是要有所准备,不要到时候连题目都看不懂。难度可以说是很难了,考的非常细,我选的C++。要注意不会做也不要乱选,否则会影...
2018-04-14 14:54:21
13708
原创 [Leetcode] 454. 4Sum II
Description: Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.To make problem a bit easier, all A, B, C, D h...
2018-03-18 21:23:06
319
原创 [Leetcode] 350. Intersection of Two Arrays II
Description: 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 a...
2018-03-18 20:45:41
300
原创 [Leetcode] 349. Intersection of Two Arrays
Description: Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note: Each element in the result must be unique. T...
2018-03-18 20:33:07
223
原创 BST/二叉树层序遍历
利用队列的FIFO特性来实现层序遍历。初始化:创建队列q,root入队。只要队列不为空:存队首元素,把队首元素pop出来,打印队首元素。判断它是否有左孩子,如果有,则左孩子入队;判断是否有右孩子,如果有,则右孩子入队(先判断左孩子再右孩子是因为这里一层中遍历假定从左到右)。有点像利用栈的前序遍历,但是栈是LIFO,因此假如要进行前序遍历,则入栈的时候是先判断并入右孩子”go” comm...
2018-03-17 15:00:17
695
原创 [Leetcode]144, 94, 145二叉树前中后序遍历的非递归实现
144. Binary Tree Preorder TraversalDescription: Given a binary tree, return the preorder traversal of its nodes’ values.For example: Given binary tree [1,null,2,3], 1 \ 2 / ...
2018-03-17 14:26:20
305
原创 [Leetcode] 11. Container With Most Water
Description: Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0...
2018-03-15 09:17:51
257
原创 堆和堆排序
堆与队列基本概念普通队列: FIFO 优先队列:有优先级的队列,可以用堆来实现。 二叉堆:最大堆MaxHeap满足父节点的值大于任一子节点,最小堆MinHeap反之。且二叉堆必须是一个完全二叉树,这个性质让它可以用数组来实现。堆的基本存储由于有完全二叉树的性质,我们把它们按层序遍历的方式编号,根节点是1(不是0!),以此类推。设某节点的编号为k,则它的parent = k/...
2018-03-14 23:15:32
243
原创 [Leetcode] 345. Reverse Vowels of a String
Description: Write a function that takes a string as input and reverse only the vowels of a string.Example 1: Given s = “hello”, return “holle”.Example 2: Given s = “leetcode”, return “leotcede...
2018-03-14 19:35:50
260
原创 [Leetcode] 344. Reverse String
Description: Write a function that takes a string as input and returns the string reversed.Example: Given s = “hello”, return “olleh”.考虑空字符串,也属于reversed string.解法一: 基本思想:对撞指针。 思路:从头从尾分别同时遍历,...
2018-03-14 09:56:38
202
原创 [Leetcode] 125. Valid Palindrome
Description: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example, “A man, a plan, a canal: Panama” is a palindrome. “race a ca...
2018-03-13 23:53:15
209
原创 排序算法大总结
选择排序思路:从最左边的元素开始,逐个遍历,找到这一趟中的最小值,存到minIndex里面,最后这一趟结束,将它和这一趟开始遍历的位置i上的元素swap,直到最后一个位置上也就位。相当于选择出每一趟最小的元素,然后把它放到这一趟开始的地方。基础版:void selectionSort(int arr[], int n){ for(int i = 0 ; i &...
2018-03-13 21:51:59
302
原创 计算机网络+计算机组成原理+操作系统高频笔试面试题
面经网络的一些基本知识,比如OSI,TCP/IP,以及某些层的具体功能。操作系统线程进程问题 网络中的OSI七层模型,设计模式 OSI七层中考到了物理层和传输层特性 线程进程预防死锁的机制原理 为什么现在的网络最后采用了TCP/IP参考模型而没用OSI参考模型? 请说一下HTTP请示的基本过程(IBM) TCP/IP 建立连接的过程?(3-way shake) 答:在TCP/IP...
2018-03-12 23:34:46
5709
原创 [机器学习] 线性回归算法 (Linear Regression)
回归问题在回归问题中,我们具体要预测的是一个具体的数值,而不是分类。对于回归问题,比如,我们可以根据房屋的大小预测房屋的价格,在这里只有一个样本特征,就是房屋的大小,为了实现这个,我们需要在两维空间中表示。如横轴代表房屋大小,纵轴就是房屋的价格,也就是我们要预测的数值。但是在分类问题里,假如样本有两维特征,如鸢尾花花瓣的大小与叶子的宽度,我们只需要二维空间中就能将它们分类,只需把用不同颜色...
2018-03-12 23:19:47
881
原创 [Leetcode] 88. Merge Sorted Array
Description: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note: You may assume that nums1 has enough space (size that is greater or equal to m + n) t...
2018-03-12 11:07:35
392
原创 [Leetcode] 75. Sort Colors
Description: Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use t...
2018-03-11 21:00:16
212
原创 [机器学习] k近邻算法 (kNN)
kNN算法基本思路kNN算法通过计算当前测试样本与离它最近的k个点的距离,进行投票,得到它最有可能的分类结果。特点首先来看看机器学习算法的基本流程: 由此可见kNN算法的特点: 1. k近邻算法是非常特殊的,可以认为是没有模型的算法。 2. 为了和其他算法统一,可以认为训练数据集就是模型本身。这也是scikit-learn在封装的时候的思路,来和其他算法统一。由此,每...
2018-03-11 14:32:36
512
原创 [Leetcode] 80. Remove Duplicates from Sorted Array II
Description: Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice? 由于follow up Problem 26,因此还是要求in-place。Example: Given sorted array nums = [1,1,1,2,2,3], 仍旧是排好序的数组 ...
2018-03-11 10:46:16
176
原创 [Leetcode] 26. Remove Duplicates from Sorted Array
Description: Given a sorted array, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this b...
2018-03-11 00:36:05
171
原创 [Leetcode] 27. Remove Element
Description: Given an array and a value, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input...
2018-03-10 17:13:26
188
原创 [Leetcode] 167. Two Sum II - Input array is sorted
Description: Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of th...
2018-03-08 09:08:48
175
原创 [Leetcode] 283. Move Zeroes
Description: Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.
2018-03-07 10:03:17
214
原创 算法笔记-快速排序(Quick Sort)之Duplicate Keys
问题描述: 当数组中有很多重复的元素(Dupicate Keys)时,采用3-way partitioning,即把array分成三部分,一部分是小于duplicate keys的,一部分是等于duplicate keys,还有一部分是大于duplicate keys。当然,一轮partition只能让一种duplicate keys归位,如果其他数字也有duplicate的情况,则需要进行下一...
2018-03-05 21:46:48
675
原创 [Leetcode] 215. Kth Largest Element in an Array
Description: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example, Given [3,2,1,5,6,4] and k = 2...
2018-03-05 19:14:14
182
原创 算法笔记-快速排序(Quick Sort)之Selection
Quick-Selection问题描述: Goal: 给了一个有N个元素的数组,找出最大的第K个元素。(或返回最大or最小的K个) Ex: Min(k = 0), Max(k = N-1), Medium(k = N/2)思路: 给数组Partition(如果是返回最大or最小的K个元素不一定要排序,因为没要求返回排好序的K个数,但Partition用的是Quick Sort的),找到第...
2018-03-04 12:46:37
236
原创 算法笔记-快速排序(Quick Sort)
看了教科书上的快排,又对比了“Algorithm 4th”里的快排,感觉后者更加简洁清晰,而且成功cover极端情况,故决定采用“Algorithm 4th”里面的快排代码。 算法思路: 一轮 QuickSort Partition有两个phase: phase 1:重复步骤直到i, j指针交叉从左向右扫描i指针(只要满足a[i]<a[lo],当然,一开始把a[lo]作为pivo...
2018-03-03 23:30:28
357
原创 [Leetcode] 771. Jewels and Stones
Description: 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 m...
2018-02-23 23:47:38
374
原创 [Leetcode] 561. Array Partition I
Description: Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), …, (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as l...
2018-02-23 19:48:23
177
原创 [Leetcode] 1. Two Sum
Description Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the ...
2018-02-23 19:36:46
178
原创 Computer Networks | OUTLINE 1.2 Network Hardware
Computer Networks | OUTLINE 1.2 Network Hardware
2017-08-08 03:25:17
415
原创 数据结构期末复习
notes about data structurepreparing for final examsorganize and summarize the knowledge
2017-01-04 16:49:46
445
空空如也
Leetcode 345代码哪里出错了,求解答!!
2018-03-14
关于动态分配的编程题 求助!!!
2016-01-08
TA创建的收藏夹 TA关注的收藏夹
TA关注的人