MySQL安装(Ubuntu系统)
安装
1 | apt-get install mysql-server |
安装过程中输入root账号密码 rootpassword
配置
因为安装成功后通常只有本地root账户,所以需配置远程用户。
1 | mysql -u root -u rootpassword |
大小写
Ubuntu安装mysql后发现大小写敏感
1 | mysql> show variables like "%case%"; |
1 | apt-get install mysql-server |
安装过程中输入root账号密码 rootpassword
因为安装成功后通常只有本地root账户,所以需配置远程用户。
1 | mysql -u root -u rootpassword |
Ubuntu安装mysql后发现大小写敏感
1 | mysql> show variables like "%case%"; |
1、下载JDK8解压至/opt/jdk/jdk8 相关命令:tar zxvf
2、配置环境变量
1 | sudo vi ~/.bashrc |
3、java -version 发现配置无效
原来系统存在默认JDK(OpenJDK),为了将新安装的JDK设成系统默认JDK,需进行如下操作。
1 |
|
4、java -version发现配置成功
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra space?
两个node,速度不同,循环
slow 为 慢
fast为快
1 | /** |
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given 1->1->2, return 1->2.
Given 1->1->2->3->3, return 1->2->3.
1 | 站在当前节点的角度,设置其next。 |
1 | /** |
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
最初思路,第一手股票遇第一个极大值卖出,然后等极小值(必须接下来有其他涨幅(这里需))买入。
当在某一时刻时,可买时,找下一时刻极小值且不为最后元素;可卖时找找极大值。
1 | public class Solution { |
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
click to show spoilers.
Have you thought about this?
Here are some good questions to ask before coding. Bonus points for you if you have already thought through this!
If the integer’s last digit is 0, what should the output be? ie, cases such as 10, 100.
Did you notice that the reversed integer might overflow? Assume the input is a 32-bit integer, then the reverse of 1000000003 overflows. How should you handle such cases?
For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.
Update (2014-11-10):
Test cases had been added to test the overflow behavior.
1 | public class Solution { |
1 | //逻辑混乱 |
1 | //厉害答案。。。 |
Given two binary trees, write a function to check if they are equal or not.
Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
1 | //开始疏忽了其中一个节点为空的情况,val也忘了比较。。。 |
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.
找到子节点,返回最大深度值。
1 |
|
Given an array of integers, every element appears twice except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
1 | //第一题,无脑超时 |