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

摘要:数据结构与算法3- 二叉搜索树 小书匠 数据结构与算法 算法工程师 1. 二叉搜索树的定义: 二叉搜索树是一颗二叉树,可以为空。满足以下性质: 非空左子树的所有键值小于其根节点的键值 非空右子树的所有键值大于其根节点的键值 2. 二叉搜索树的基本操作: 查找最小值:在树的最左分支的端节点上 查找最大 阅读全文
posted @ 2018-10-11 20:35 NaiveCoder 阅读(674) 评论(0) 推荐(0)
摘要:数据结构与算法2-二叉树 小书匠 算法工程师 数据结构与算法 1. 二叉树 定义:一颗二叉树由一个根节点和左右两个子树组成 结构变体: 满二叉树:所有分支节点都存在左子树和右子树,而且所有的叶子节点都在同一层 完全二叉树:二叉树的叶子节点只出现在最下层和次下层,而且最下层的叶节点集中在树的左部 树节 阅读全文
posted @ 2018-10-11 20:29 NaiveCoder 阅读(224) 评论(0) 推荐(0)
摘要:数据结构与算法1- 线性表与散列表 小书匠 算法工程师 数据结构与算法 1. 链表 java.util.LinkedList<> 既实现了List<> 接口,又实现了Deque<> 接口 2. 队列和栈 java.util.ArrayDeque<> * 单端队列API: * boolean offe 阅读全文
posted @ 2018-10-09 10:47 NaiveCoder 阅读(458) 评论(0) 推荐(0)
摘要:Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example: Example: 阅读全文
posted @ 2017-06-17 11:07 NaiveCoder 阅读(99) 评论(0) 推荐(0)
摘要:Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng 阅读全文
posted @ 2017-06-16 10:25 NaiveCoder 阅读(111) 评论(0) 推荐(0)
摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the 阅读全文
posted @ 2017-06-14 21:38 NaiveCoder 阅读(118) 评论(0) 推荐(0)
摘要:Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return: Note: All inputs will be i 阅读全文
posted @ 2017-06-14 19:30 NaiveCoder 阅读(116) 评论(0) 推荐(0)
摘要:The count-and-say sequence is the sequence of integers with the first five terms as following: 1 is read off as "one 1" or 11.11 is read off as "two 1 阅读全文
posted @ 2017-06-14 19:02 NaiveCoder 阅读(108) 评论(0) 推荐(0)
摘要:Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the rans 阅读全文
posted @ 2017-06-12 16:12 NaiveCoder 阅读(174) 评论(0) 推荐(0)
摘要:Write a function that takes a string as input and returns the string reversed. 阅读全文
posted @ 2017-06-12 15:13 NaiveCoder 阅读(97) 评论(0) 推荐(0)
摘要:Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 非常容易的一道题目,注意各种特殊情况,先列举出c 阅读全文
posted @ 2017-06-11 21:25 NaiveCoder 阅读(113) 评论(0) 推荐(0)
摘要:Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"]. 这个题目不 阅读全文
posted @ 2017-06-08 21:58 NaiveCoder 阅读(91) 评论(0) 推荐(0)
摘要: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  阅读全文
posted @ 2017-06-08 20:51 NaiveCoder 阅读(110) 评论(0) 推荐(0)
摘要:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpo 阅读全文
posted @ 2017-06-08 20:16 NaiveCoder 阅读(130) 评论(0) 推荐(0)
摘要:Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space. 第一 阅读全文
posted @ 2017-06-08 16:45 NaiveCoder 阅读(131) 评论(0) 推荐(0)
摘要:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文
posted @ 2017-06-08 15:53 NaiveCoder 阅读(94) 评论(0) 推荐(0)
摘要:Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. 阅读全文
posted @ 2017-06-08 11:57 NaiveCoder 阅读(163) 评论(0) 推荐(0)
摘要:LeetCode汇总 阅读全文
posted @ 2017-06-08 09:02 NaiveCoder 阅读(184) 评论(0) 推荐(0)
摘要:Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of 阅读全文
posted @ 2017-06-07 22:13 NaiveCoder 阅读(98) 评论(0) 推荐(0)
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib 阅读全文
posted @ 2017-06-07 22:01 NaiveCoder 阅读(120) 评论(0) 推荐(0)