随笔分类 - 数据结构与算法
摘要:import java.util.Random; public class Sorting { /** * For each element, compare with all the elements before it and swap position accordingly * https:
阅读全文
摘要:思路:递归实现,注意翻转的规律,以左子树作为根,找到左子树最右边的节点作为原有right子树和根的父节点。
阅读全文
摘要:Leetcode: https://leetcode.com/problems/implement-trie-prefix-tree/ class Trie { Character curChar; boolean isEnd; Map<Character, Trie> children = new
阅读全文
摘要:分解质因数求最大公约数求最小公倍数牛顿迭代求平方根分解质因数import java.util.ArrayList;import java.util.List;public class Solution { // 返回质因数分解 List getPrimeFactors(int n) { ...
阅读全文
摘要:根据冲突解决的不同,可分为seperate chaining hash table, linear probing hash table, quadratic probing hash table.自己实现的最简单饿seperate chaining hash table。package ADT;i...
阅读全文
摘要:参考:http://blog.csdn.net/fightforyourdream/article/details/16843303import java.util.ArrayList;import java.util.Iterator;import java.util.LinkedList;imp...
阅读全文
摘要:转+修改整理。import java.util.ArrayList;import java.util.Comparator;import java.util.HashMap;import java.util.PriorityQueue;import java.util.Stack;/** * htt...
阅读全文
摘要:检测链表是否是palindrome.思路1:翻转并比较。思路2:迭代。思路3:递归。 public static boolean isPalindrome(LinkedListNode head) { LinkedListNode fast = head; Link...
阅读全文
摘要:You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1’s ...
阅读全文
摘要:参考http://www.cnblogs.com/jdflyfly/p/3819162.html
阅读全文
摘要:Implement an algorithm to delete a node in the middle of a single linked list, given only access to that node.
阅读全文
摘要:Implement an algorithm to find the kth to last element of a singly linked list.
阅读全文
摘要:Write code to remove duplicates from an unsorted linked list.
阅读全文
摘要:Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring ( i.e., “waterbottle” is a rotation of “erbottlewat”).
阅读全文
摘要:Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0.
阅读全文
摘要:Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?
阅读全文
摘要:Given an input string, reverse the string word by word.
阅读全文
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation.
阅读全文
摘要:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
阅读全文
摘要:Sort a linked list using insertion sort.
阅读全文

浙公网安备 33010602011771号