CHuiL

230. Kth Smallest Element in a BST

leetcode

题目 Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ BST’s total elements. 题意 给定二叉搜索树,求出倒数第k个数 题解 ...

215. Kth Largest Element in an Array

leetcode

题目 Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. 题意 求无序数组中的第k大元素 例子 Input: [3,2,1,5,6,4] and k = 2 Ou...

378. Kth Smallest Element in a Sorted Matrix

leetcode

题目 Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix. Note that it is the kth smallest element in the sorted order,...

179. Largest Number

leetcode

题目 Given a list of non negative integers, arrange them such that they form the largest number. 题意 给定整型数组,求出该数字组合成最大值的字符串 例子 Input: [3,30,34,5,9] Output: “9534330” 题解 设有x y,则当xy>yx时,我们就认为x>...

平衡二叉树

为什么需要索引 假设现在有100000条从0到10000且从大到小排列的整型数据,1条数据的大小假设(真的只是假设)是1KB,操作系统的每次I/O数据块(页)大小是8KB。 如果现在我要查找其中 50001 这个数据值,有如下几个方式: 1.最蠢的方式,遍历,每次遍历到一个值,就用这个值跟目标值做对比,如果不等于那么查找下一个。这样的话那么每次I/O是8条数据,目标数据在50001/8...

数据库中基本概念的理解

数据库的完整性 指数据的正确性和相容性; 正确性指数据是符合现实世界语义的 相容性指数据库同一对象在不同关系表中的数据是符合逻辑的。 数据库完整性是为了防止数据库中存在不符合语义的数据。 实体完整性(定义主键) 利用约束 PRIMARY KEY来定义。 参照完整性(外键) 利用FOREIGN KEY来定义 用户定义的完整性 各种约束条件。 使用触发器 触发器是用户定义在关...

17. Letter Combinations of a Phone Number

leetcode

题目 Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) ...

152. Maximum Product Subarray

leetcode

题目 Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. 题目 求连续子数组乘积最大的值 例子 Input: [-2,3,-4] Output: 24 题解 使用动态...

5. Longest Palindromic Substring

leetcode

题目 Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. 题意 给定字符串s,求出s的最长回文子串 例子 Input: “babad” Output: “bab” Note: “aba” is also a v...

395. Longest Substring with At Least K Repeating Characters

leetcode

题目 Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than k times. 题意 给一个字符串s,求出该字符串中最长子串T,该T满足所有字符都大于...