数据结构
文章平均质量分 68
ZHANGTAOZAQaq
这个作者很懒,什么都没留下…
展开
-
Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?在一个单链表中找到you原创 2014-06-01 14:09:05 · 497 阅读 · 0 评论 -
在一个字符串中把大写字母放到字符串中小写字母的后面(不能改变字母的相对位置)
设置两个下标p1、p2 同时指向字符串的末尾,让p1找到第一次出现为大写的字母的位置,然后从p1至p2两两交换,之后让p1--,p2--,重复以上,直到p1小于0为止 public void swapCharacter(char[] ch){ if(null==ch||0==ch.length)return; int p1 =ch.length-1; in原创 2014-12-24 12:07:44 · 2891 阅读 · 1 评论 -
最长不重复子串
public static int lengthOfLongestSubstring(String s) { if(s==null||s.length()==0)return 0; int[] t = new int[256]; int start =0; int end = 0; int max原创 2014-11-19 21:11:00 · 403 阅读 · 0 评论 -
B 树、B+ 树、B* 树
从B树、B+树、B* 树谈到R树 作者:July、weedge、Frankie。编程艺术室出品。说明:本文从B树开始谈起,然后论述B+树、B*树,最后谈到R树。其中B树、B+树及B*树部分由weedge完成,R树部分由Frankie完成,全文最终由July统稿修订完成。出处:http://blog.csdn.net/v_JULY_v 。转载 2014-09-25 00:18:24 · 562 阅读 · 0 评论 -
全排列
全排列以递归的方式实现,现在xia原创 2014-06-20 21:53:02 · 572 阅读 · 0 评论 -
红白蓝三色小球排列成有序的红白蓝三色的同颜色在一起的小球组
问题描述:我们将乱序的红白蓝三色小球排列成有序的红白蓝三色的同颜色在一起的小球组。这个问题之所以叫荷兰国旗,是因为我们可以将红白蓝三色小球想象成条状物,有序排列后正好组成荷兰国旗。如下图所示: 这个问题,类似快排中partition过程。不过,要用三个指针,一前begin,一中current,一后end,俩俩交换。1、current遍历,整个数组序列,cu转载 2014-06-21 13:07:43 · 3528 阅读 · 0 评论 -
堆排序
package com.qetch.interview;import java.util.Set;import java.util.TreeSet;/* * 输入一个无序的数组,用堆排序进行排序 * 利用堆排序来排序一个无序的数组 * 算法思想 * 1.首先先建立最大堆 * 2.在最大堆中先用a[0]与最后一个元素交换,此时得到无序区和有序区, * 最后一个元素为有序区a[0原创 2014-06-20 09:42:06 · 469 阅读 · 0 评论 -
正则表达式语法
字 符说明\将下一字符标记为特殊字符、文本、反向引用或八进制转义符。例如,"n"匹配字符"n"。"\n"匹配换行符。序列"\\"匹配"\","\("匹配"("。^匹配输入字符串开始的位置。如果设置了 RegExp 对象的 Multiline 属性,^ 还会与"\n"或"\r"之后的位置匹配。$原创 2014-06-02 22:37:38 · 565 阅读 · 0 评论 -
判断单链表是否有环
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?原创 2014-06-01 00:02:36 · 511 阅读 · 0 评论 -
非递归遍历二叉树
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].题目原创 2014-05-31 22:33:37 · 466 阅读 · 0 评论 -
两单链表的差集
已知集合A和B的元素分别用不含头结点的单链表存储,函数difference()用于求解集合A与B的差集,并将结果保存在集合A的单链表中。例如,若集合A={5,10,20,15,25,30},集合B={5,15,35,25},完成计算后A={10,20,30}。package com.qetch.interview;import java.util.Scanner;原创 2014-05-28 15:16:14 · 1027 阅读 · 0 评论 -
数组的子数组之和的最大值和下标的开始与结束
题目描述:给一个一维数组求其zish原创 2014-05-28 20:17:19 · 1545 阅读 · 0 评论 -
Binary Tree Level Order Traversal
题目描述:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \原创 2014-06-28 14:20:04 · 391 阅读 · 0 评论 -
Populating Next Right Pointers in Each Node
题目地址:https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node/;原创 2014-06-22 12:47:49 · 468 阅读 · 0 评论 -
正则匹配任意字符(常用正则表达式的书写)
http://www.unibetter.com/deerchao/zhengzhe-biaodashi-jiaocheng-se.htm 正则教程(注:元字符包括\ | ( ) [ ] { } ^ $ * + ? . )匹配中文字符的正则表达式: [\u4e00-\u9fa5]评注:匹配中文还真是个头疼的事,有了这个表达式就好办了匹配双字节字符(包括汉字在转载 2014-06-04 14:29:30 · 37570 阅读 · 0 评论 -
判断两个二叉树是否相同
题目描述: 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原创 2015-07-28 10:39:35 · 894 阅读 · 0 评论