摘要:
1.Remove Nth Node From End of ListGiven a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: ... 阅读全文
摘要:
public static void swap(int data[],int p,int q){ int temp = data[p]; data[p] = data[q]; data[q] = temp; }public static void... 阅读全文
摘要:
1.TriangleGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, gi... 阅读全文
摘要:
1.Maximum Depth of Binary Tree这是道简单的分治习题了分:左子树最大深度右子树最大深度治:最大深度等于max(左子树,右子树)+1public class Solution { public int maxDepth(TreeNode root) { ... 阅读全文
摘要:
1 package sorting; 2 3 import java.util.*; 4 //import java.util.Comparator; 5 //import java.util.PriorityQueue; 6 //import java.util.Queue; 7... 阅读全文
摘要:
一、插入排序 数组: 1 void insertionSort(int[] a){ 2 int j; 3 for(int p = 1;p0;j--){ 6 if(tmp0&&tmp.compareTo(a[j-1])head.next.val){12 ... 阅读全文
摘要:
本文转载自http://sarin.iteye.com/blog/603684/先来看一个例子,代码如下: Java代码 publicclassTest{publicstaticvoidmain(String[]args){Stringstr="abc";Stringstr1="abc";Strin... 阅读全文
摘要:
程序来自Program Creek前序遍历:Preorder binary tree traversal is a classic interview problem about trees. The key to solve this problem is to understand the fo... 阅读全文