
数据结构
hf寒沨
Coding...
展开
-
数据结构--单链表
数据结构--单链表在数据结构中 链表学习最为基础原创 2016-02-14 16:34:19 · 371 阅读 · 0 评论 -
【LeetCode】725. Split Linked List in Parts
Problem:Given a (singly) linked list with head node root, write a function to split the linked list into k consecutive linked list "parts".The length of each part should be as equal as possible: no tw...原创 2018-05-09 15:14:07 · 333 阅读 · 3 评论 -
【LeetCode】338. Counting Bits
Problem:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num = 5...原创 2018-04-25 10:30:53 · 157 阅读 · 0 评论 -
【LeetCode】238. Product of Array Except Self
Problem:Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and i...原创 2018-04-25 11:28:48 · 145 阅读 · 0 评论 -
【LeetCode】328. Odd Even Linked List
Problem:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do i...原创 2018-05-04 16:27:50 · 375 阅读 · 0 评论 -
【LeetCode】19. Remove Nth Node From End of List
Given a linked list, remove the n-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the li...原创 2018-05-04 16:35:14 · 139 阅读 · 0 评论 -
【LeetCode】92. Reverse Linked List II
Problem:Reverse a linked list from position m to n. Do it in one-pass.Note: 1 ≤ m ≤ n ≤ length of list.Example:Input: 1->2->3->4->5->NULL, m = 2, n = 4Output: 1->4->3->2->5...原创 2018-05-04 16:51:46 · 151 阅读 · 0 评论 -
【LeetCode】234. Palindrome Linked List
Problem:Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?题目:给定一个单链表,判断是否为回文?最好时间复杂度O(n),空间复杂度为 O(1)。 思路:除去要求,最简单的方法则是用stack...原创 2018-05-05 21:00:24 · 220 阅读 · 0 评论 -
Java中数组赋值
1,数组操作中,可以使用等于(=)赋值,注意:此时新数组只是指向原数组的存储空间,并没有重新申请新的空间。2,第二种使用System.ararycopy方法System.arraycopy(originalArray, 0, targetArray, 0, originalArray.length);此时,新数组重新申请存储地址空间,再将原数组中数据拷贝过来。...原创 2018-07-10 14:53:06 · 14342 阅读 · 0 评论 -
【数据结构】Trie Tree:字典树(前缀树)的实现
字典树又称为前缀树或Trie树,是处理字符串常见的数据结构。假设组成所有单词的字符仅为a-z。字典树介绍字典树是一种树形结构,优点是利用字符串的公共前缀来节约存储空间,比如加入"abc"、“abcd”、“abd”、“b”、“bcd”、“efg”、"hik"之后,字典树如图所示。基本特性根节点没有字符路径。除了根节点外,每一个节点都被一个字符路径找到。从根节点到某一节点,将路径上经过的...原创 2019-01-19 15:54:31 · 790 阅读 · 0 评论 -
【Java】HashMap源码分析
HashMap源码分析继承和接口静态变量关键方法1. hashCode()2. equals()3. hash()继承和接口继承AbstractMap.java实现接口Map,Cloneable,Serializable静态变量初试容量默认是16 -必须是2的次方 /** * The default initial capacity - MUST be a ...原创 2019-04-27 00:33:00 · 458 阅读 · 0 评论 -
【LeetCode】80. Remove Duplicates from Sorted Array II
Problem:Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.Do not allocate extra space for another array, you must do this ...原创 2018-05-02 10:45:47 · 172 阅读 · 0 评论 -
【LeetCode】82. Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.Example 1:Input: 1->2->3->3->4->4->5Output: 1->2-&g...原创 2018-05-02 00:43:39 · 110 阅读 · 0 评论 -
借用栈实现单链表逆向倒序输出
借用栈实现单链表逆向倒序输出原创 2017-08-11 19:59:24 · 3332 阅读 · 0 评论 -
斐波那契数列实用解法
斐波那契数列实用解法,时间复杂度为O(n)原创 2017-09-11 17:02:22 · 263 阅读 · 0 评论 -
【LeetCode】 69. Sqrt(x)
题目:求平方根。。。必须返回的是整数,就是小数点要舍弃。思路:直接用轮子。。。sqrt()代码:class Solution { public int mySqrt(int x) { return (int)Math.sqrt(x); }}...原创 2018-04-03 22:44:46 · 159 阅读 · 0 评论 -
【LeetCode】461. Hamming Distance
Problem:The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.题目:求汉明距离,即两个数不同位数的...原创 2018-04-23 09:26:34 · 185 阅读 · 0 评论 -
【LeetCode】448. Find All Numbers Disappeared in an Array
Problem:Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array....原创 2018-04-23 10:31:26 · 135 阅读 · 0 评论 -
【LeetCode】771. Jewels and Stones
Problem:You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in Sis a type of stone you have. You want to know how many of ...原创 2018-04-23 11:47:00 · 233 阅读 · 0 评论 -
【LeetCode】561. Array Partition I
Problem:Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large...原创 2018-04-23 14:30:20 · 145 阅读 · 0 评论 -
【LeetCode】821. Shortest Distance to a Character
Problem:Given a string S and a character C, return an array of integers representing the shortest distance from the character C in the string.题目:给定一个字符串S和字符C,返回一个整型数组,数组每一位表示字符串对应下标位字符距离C字符的最短距离。思路:首先...原创 2018-04-23 15:52:34 · 513 阅读 · 2 评论 -
【LeetCode】371. Sum of Two Integers
Problem:Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example:Given a = 1 and b = 2, return 3.题目:计算a和b的和,不使用加减运算符。思路:使用异或,与等逻辑运算。(参考计算机组成原理中补码加减法等)使用异或...原创 2018-04-23 16:56:41 · 117 阅读 · 0 评论 -
【LeetCode】3. Longest Substring Without Repeating Characters
Problem:Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "b", wi...原创 2018-05-01 17:15:54 · 131 阅读 · 0 评论 -
【算法】GeoHash
两篇介绍的不错的文章,先记录下https://www.cnblogs.com/mafeng/p/7908620.htmlhttps://www.cnblogs.com/LBSer/p/3392491.html原创 2019-09-21 23:26:29 · 173 阅读 · 0 评论