翻转单链表

package com.liangyumingblog;

public class LinkList
{
    private class Node
    {
        int value;

        Node next;

        public Node(int value, Node next)
        {
            this.value = value;
            this.next = next;
        }
    }

    private Node head = new Node(-1, null);

    private int size = 0;

    public void add(int value)
    {
        size++;
        Node current = head;
        while (current.next != null)
        {
            current = current.next;
        }
        current.next = new Node(value, null);
    }

    public Node getLast()
    {
        Node current = head;
        while (current.next != null)
        {
            current = current.next;
        }
        return current;
    }

    public Node removeLast()
    {
        Node current = head;
        while (current.next.next != null)
        {
            current = current.next;
        }
        Node tmp = current.next;
        current.next = null;
        tmp.next = null;
        return tmp;
    }

    public void reverse()
    {
        int length = 0;
        while (length != size)
        {
            insert(length, removeLast());
            length++;
        }
    }

    public boolean insert(int index, Node node)
    {
        if (index > size)
        {
            return false;
        }
        int now = 0;
        Node current = head;
        while (now != index)
        {
            ++now;
            current = current.next;
        }
        Node tmp = current.next;
        current.next = node;
        node.next = tmp;
        return true;
    }

    @Override
    public String toString()
    {
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("[");
        Node current = head;
        while (current.next != null)
        {
            if (head != current)
            {
                stringBuffer.append(current.value);
                stringBuffer.append(", ");
            }
            current = current.next;
        }
        stringBuffer.append(current.value);
        stringBuffer.append("]");
        return stringBuffer.toString();
    }
}

 

为了看PDF买了个IPAD

结果是觉得有点太大,在车上看简直扑街。。。

为了搞个下载机,买了个树莓派,结果还是坏的。。扑街。。

为了打游戏上了个电信,结果上传只有2mkbps,扑街。。。

总结是冲动消费不可取。。。。

趁着还没睡着,记一个今天学到的小小的分页trick

(totalrow+singlePageSize-1 )/singlePageSize

为什么说是个小trick呢

直观上我们做分页算法应该是这样的

return totalSize%singlePageSize!=0?totalSize/singlePageSize+1:totalSize/singlePageSize;

但是呢,最开始提到的算法,如果total/single有余数,由于int的直接截取的性质,所以totalrow/singlePageSize是向下取整了,但是这个余数加上(singlePageSize-1)再去除singlePagesize就刚好能够+1

否则因为(singePageSize-1)/SinglePageSize向下取整的性质,就变成了+0。所以说这里这个小Trick我还真没想到过,很巧妙

单点登录要素

单点登录的要素

中央认证服务器:用于生成ticket
应用服务器:要约定一个页面用于接收ticket,并写入相同域名内的cookie

技术上要解决

生成ticket的机制
ticket的失效机制

需要权衡的

每次验证ticket都需要到中央服务器认证:增加内部流量
通过租约:会有失效时间,不能保证马上所有位置都失效
中央服务器push到业务端通知失效:中央服务器压力大

Golang.Sort

package main

import "fmt"

func main() {
	var nums = [] int{5, 4, 3, 2, 1, 4, 5, 3}
	sort(nums, len(nums))
	fmt.Println(nums)
}
func sort(nums []int, length int) {
	for i := 0; i < length; i++ {
		for j := 0; j < length; j++ {
			if (nums[i] > nums[j]) {
				swap(&nums[i], &nums[j])
			}
		}
	}
}
func swap(a *int, b *int) {
	*a, *b = *b, *a
}

 

Golang/HelloWorld

就是简单的输出一些字符串,用以学习Go的package和实际的path的关系

package main

import (
	"fmt"
	"HelloWorld/heelo"
)

func main() {
	p()
}
func p() {
	fmt.Println("Hello", "HelloTat")
	heelo.Hehe()
}
package heelo

import "fmt"

func Hehe() {
	fmt.Println("this is Hello2")
}

 

有效交流

  • 讲真。。不想招人就不要浪费彼此时间吧;
  • 请不要做出做不到的承诺;
  • 面试官面试的内容总得像看过我的博客和github吧;
  • HR打电话前能不能提前发个邮件;
  • 面试的内容内否不包括Spring等ChangeLog;
  • 程序员的能力在于抽象问题并提供一个可能的解决方案,而不是工具或者代码的手抄员;