随笔分类 -  数据结构与算法

1 2 3 4 5 ··· 9 下一页
摘要:import java.util.Random; public class Sorting { /** * For each element, compare with all the elements before it and swap position accordingly * https: 阅读全文
posted @ 2022-10-27 04:34 jdflyfly 阅读(60) 评论(0) 推荐(0)
摘要:思路:递归实现,注意翻转的规律,以左子树作为根,找到左子树最右边的节点作为原有right子树和根的父节点。 阅读全文
posted @ 2017-09-04 23:04 jdflyfly 阅读(139) 评论(0) 推荐(0)
摘要:Leetcode: https://leetcode.com/problems/implement-trie-prefix-tree/ class Trie { Character curChar; boolean isEnd; Map<Character, Trie> children = new 阅读全文
posted @ 2014-10-19 17:14 jdflyfly 阅读(264) 评论(0) 推荐(0)
摘要:分解质因数求最大公约数求最小公倍数牛顿迭代求平方根分解质因数import java.util.ArrayList;import java.util.List;public class Solution { // 返回质因数分解 List getPrimeFactors(int n) { ... 阅读全文
posted @ 2014-09-17 17:11 jdflyfly 阅读(227) 评论(0) 推荐(0)
摘要:根据冲突解决的不同,可分为seperate chaining hash table, linear probing hash table, quadratic probing hash table.自己实现的最简单饿seperate chaining hash table。package ADT;i... 阅读全文
posted @ 2014-07-14 00:37 jdflyfly 阅读(758) 评论(0) 推荐(0)
摘要:参考:http://blog.csdn.net/fightforyourdream/article/details/16843303import java.util.ArrayList;import java.util.Iterator;import java.util.LinkedList;imp... 阅读全文
posted @ 2014-07-09 00:16 jdflyfly 阅读(384) 评论(0) 推荐(0)
摘要:转+修改整理。import java.util.ArrayList;import java.util.Comparator;import java.util.HashMap;import java.util.PriorityQueue;import java.util.Stack;/** * htt... 阅读全文
posted @ 2014-07-08 22:42 jdflyfly 阅读(227) 评论(0) 推荐(0)
摘要:检测链表是否是palindrome.思路1:翻转并比较。思路2:迭代。思路3:递归。 public static boolean isPalindrome(LinkedListNode head) { LinkedListNode fast = head; Link... 阅读全文
posted @ 2014-07-08 00:23 jdflyfly 阅读(182) 评论(0) 推荐(0)
摘要: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 ... 阅读全文
posted @ 2014-07-08 00:12 jdflyfly 阅读(129) 评论(0) 推荐(0)
摘要:参考http://www.cnblogs.com/jdflyfly/p/3819162.html 阅读全文
posted @ 2014-07-08 00:11 jdflyfly 阅读(135) 评论(0) 推荐(0)
摘要:Implement an algorithm to delete a node in the middle of a single linked list, given only access to that node. 阅读全文
posted @ 2014-07-07 23:41 jdflyfly 阅读(112) 评论(0) 推荐(0)
摘要:Implement an algorithm to find the kth to last element of a singly linked list. 阅读全文
posted @ 2014-07-07 23:34 jdflyfly 阅读(129) 评论(0) 推荐(0)
摘要:Write code to remove duplicates from an unsorted linked list. 阅读全文
posted @ 2014-07-07 23:28 jdflyfly 阅读(147) 评论(0) 推荐(0)
摘要: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”). 阅读全文
posted @ 2014-07-07 23:07 jdflyfly 阅读(187) 评论(0) 推荐(0)
摘要:Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0. 阅读全文
posted @ 2014-07-07 23:03 jdflyfly 阅读(103) 评论(0) 推荐(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? 阅读全文
posted @ 2014-07-07 23:00 jdflyfly 阅读(179) 评论(0) 推荐(0)
摘要:Given an input string, reverse the string word by word. 阅读全文
posted @ 2014-07-07 22:25 jdflyfly 阅读(190) 评论(0) 推荐(0)
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation. 阅读全文
posted @ 2014-07-07 22:22 jdflyfly 阅读(564) 评论(0) 推荐(0)
摘要:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 阅读全文
posted @ 2014-07-07 21:34 jdflyfly 阅读(185) 评论(0) 推荐(0)
摘要:Sort a linked list using insertion sort. 阅读全文
posted @ 2014-07-07 21:20 jdflyfly 阅读(158) 评论(0) 推荐(0)

1 2 3 4 5 ··· 9 下一页