摘要: Description:The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.G... 阅读全文
posted @ 2015-04-16 23:44 Pickle 阅读(208) 评论(0) 推荐(0) 编辑
摘要: Description: Write a SQL query to get the second highest salary from the Employee table.+----+--------+| Id | Salary |+----+--------+| 1 | 100 ||... 阅读全文
posted @ 2015-04-16 23:17 Pickle 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 第一次刷SQL题目感觉还是不错的。这个题目(https://leetcode.com/problems/combine-two-tables/)大概是说把第一张表和第二张表连接起来。而且第二张表中的Person的Address中的属性可能为NULL。这明显就是个左外链接。?123# Write yo... 阅读全文
posted @ 2015-04-16 22:50 Pickle 阅读(395) 评论(0) 推荐(0) 编辑
摘要: Description:Write a SQL query for a report that provides the following information for each person in the Person table, regardless if there is an add... 阅读全文
posted @ 2015-04-16 22:48 Pickle 阅读(156) 评论(0) 推荐(0) 编辑
摘要: package algorithm01;import java.util.Scanner;/** * 给出先序遍历和中序遍历序列求出二叉树的后续遍历序列 * @author wxisme * */public class ToReverse { public static void main(Str... 阅读全文
posted @ 2015-04-15 22:10 Pickle 阅读(1186) 评论(0) 推荐(1) 编辑
摘要: Description:Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurall... 阅读全文
posted @ 2015-04-12 22:20 Pickle 阅读(175) 评论(0) 推荐(0) 编辑
摘要: Description: Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assume that A has enough space (siz... 阅读全文
posted @ 2015-04-11 23:04 Pickle 阅读(159) 评论(0) 推荐(0) 编辑
摘要: Description: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... 阅读全文
posted @ 2015-04-11 22:31 Pickle 阅读(173) 评论(0) 推荐(0) 编辑
摘要: Description: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct wa... 阅读全文
posted @ 2015-04-11 11:33 Pickle 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 题意:给一个数按位存放在一个int数组中,要求返回这个数加一后的数组。 懒人解法:public class Solution { public int[] plusOne(int[] digits) { java.math.BigInteger Bigdigits = new jav... 阅读全文
posted @ 2015-04-11 11:12 Pickle 阅读(198) 评论(0) 推荐(0) 编辑
摘要: TCP协议是面向连接的,相对于UDP协议来说效率较低,但是比较安全,数据不容易丢失。TCP协议类似打电话的过程,在一端拨号时必须等待对方回应,确定两端建立了连接通道才能传送信息。 在Java中TCP被封装成了类方便使用。ServerSocket类可以创建服务端并指定端口,Socket类可以建立起通... 阅读全文
posted @ 2015-04-05 10:48 Pickle 阅读(921) 评论(0) 推荐(0) 编辑
摘要: UDP协议是非面向连接的,相对于TCP协议效率较高,但是不安全。UDP协议类似发信息的过程,不管接收方是在线还是关机状态,都会把信息发送出去。但是如果接收方不处于接收信息的状态,发送出去的数据包就会丢失。convert()方法是用来转换字节数组和基本类型。/** * 创建基于udp协议的服务接受端... 阅读全文
posted @ 2015-04-05 10:36 Pickle 阅读(961) 评论(0) 推荐(0) 编辑
摘要: Java的字符串也很强大。public class Solution { public int lengthOfLastWord(String s) { if(s.length() == 0) return 0; String[] str = s.trim(... 阅读全文
posted @ 2015-04-03 18:22 Pickle 阅读(127) 评论(0) 推荐(0) 编辑
摘要: Java对二进制的支持还是比较好的,用上BIgInteger连溢出都不用考虑了。public class Solution { public String addBinary(String a, String b) { java.math.BigInteger ia = new java.m... 阅读全文
posted @ 2015-04-03 18:20 Pickle 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 判断是不是符合数独的规则。数独的规则:每一行每一列不能有重复的数字,每一个3X3方格中不能有重复的数字,但是这个题中可以为空即都是'.'。 (要养成良好的编程习惯啊,要不一点低级错误不容易发现,浪费生命!)public class Solution { public boolean isVal... 阅读全文
posted @ 2015-04-03 14:09 Pickle 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 自从JavaAPI&RegExp用熟练了之后就变得越来越任性越来越懒了):public class Solution { public int strStr(String haystack, String needle) { return haystack.indexOf(ne... 阅读全文
posted @ 2015-04-03 10:52 Pickle 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 线性表的删除操作,这里可以用ArrayList实现简单的完成。(偷懒)public class Solution { public int removeElement(int[] A, int elem) { ArrayList arr = new ArrayL... 阅读全文
posted @ 2015-04-03 10:42 Pickle 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 删除数组里重复的元素,返回数组的元素个数。可以利用set集合元素不重复的特点来保存。public class Solution { public int removeDuplicates(int[] A) { java.util.SortedSet set = ... 阅读全文
posted @ 2015-04-03 10:31 Pickle 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 依然是链表的简单操作,把两个链表按大小顺序和成一个链表,但是还是要注意细节。下面是效率不高但是简单易懂的一种解法。需要注意两个链表都为空的情况。/** * Definition for singly-linked list. * public class ListNode { * int ... 阅读全文
posted @ 2015-04-02 23:51 Pickle 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 题目意思非常简单,判断所给字符串中的括号是否匹配,需要注意的问题:)(这样是不匹配的。 public class Solution { public boolean isValid(String s) { Stack stack = new Stack(); ... 阅读全文
posted @ 2015-04-02 20:43 Pickle 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 删除链表中倒数第n个节点,需要考虑的细节:链表为空时,链表只有一个节点时,n=1时。/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ... 阅读全文
posted @ 2015-04-02 20:13 Pickle 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 程序比较简单,但是能体现基本原理。package com.wxisme.webcrawlers;import java.io.*;import java.net.*;/** * Web Crawlers * @author wxisme * */public class WebCrawlers {... 阅读全文
posted @ 2015-04-01 22:08 Pickle 阅读(379) 评论(0) 推荐(0) 编辑
摘要: 题目虽然简单但是要高效准确还是要很细心才是,粗心是BUG的最大制造者。public class Solution { public String longestCommonPrefix(String[] strs) { if(strs.length == 0) ... 阅读全文
posted @ 2015-04-01 19:42 Pickle 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 题目没有太大意思if else就能过了。public class Solution { public int romanToInt(String s) { int num = 0, i; for(i=0; i<s.length(); i++) ... 阅读全文
posted @ 2015-04-01 19:06 Pickle 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 用Java刷这道题没有太大意义。public class Solution { public boolean isPalindrome(int x) { boolean ans = false; StringBuilder sb = new Str... 阅读全文
posted @ 2015-04-01 18:48 Pickle 阅读(194) 评论(0) 推荐(0) 编辑