- 博客(16)
- 资源 (1)
- 收藏
- 关注
原创 剑指Offer-Java-旋转数组的最小数字
题目把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个非减排序的数组的一个旋转,输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。代码只需要理解旋转数组的规律即可import java.util.ArrayList;public...
2018-08-30 22:21:24 136
原创 剑指Offer-Java-用两个栈实现队列
题目用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。代码只需要来回倒就可以实现了。import java.util.Stack;public class Solution { Stack<Integer> stack1 = new Stack<Integer>(); Stack<Integ...
2018-08-30 16:50:36 162
原创 剑指Offer-Java-重建二叉树
题目输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。代码/** * Definition for binary tree * public class TreeNode { * ...
2018-08-30 16:06:29 133
原创 LeetCode-Java-893. Groups of Special-Equivalent Strings
题目You are given an array A of strings.Two strings S and T are special-equivalent if after any number of moves, S == T.A move consists of choosing two indices i and j with i % 2 == j % 2, and s...
2018-08-29 16:26:46 555
原创 LeetCode-Java-575. Distribute Candies
题目Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute...
2018-08-29 12:19:33 191
原创 LeetCode-Java-766. Toeplitz Matrix
题目A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element.Now given an M x N matrix, return True if and only if the matrix is Toeplitz.Example 1:Input:mat...
2018-08-26 10:31:26 227
原创 LeetCode-Java-872. Leaf-Similar Trees
题目Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence.假装有图For example, in the given tree above, the leaf value sequence i...
2018-08-22 12:58:34 209 2
原创 LeetCode-Java-136. Single Number
题目Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it with...
2018-08-19 16:56:23 263
原创 LeetCode-Java-559. Maximum Depth of N-ary Tree
题目Given a n-ary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.For example, given a 3-ary tree:...
2018-08-19 15:30:30 387
原创 LeetCode-SQL-620. Not Boring Movies
题目X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions.Please write a SQL query to output mo...
2018-08-19 14:32:45 202
原创 LeetCode-Java-344. Reverse String
题目Write a function that takes a string as input and returns the string reversed.Example 1:Input: "hello"Output: "olleh"Example 2:Input: "A man, a plan, a canal: Panama"Output: "amanaP :la...
2018-08-19 14:18:55 280
原创 LeetCode-Java-557. Reverse Words in a String III
题目Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: "Let's take LeetCode conte...
2018-08-19 13:46:10 299
原创 LeetCode-Java-821. Shortest Distance to a Character
题目Given a string S and a character C, return an array of integers representing the shortest distance from the character C in the string.Example 1:Input: S = "loveleetcode", C = 'e'Output: [3,...
2018-08-19 13:15:31 302
原创 LeetCode-Java-884. Uncommon Words from Two Sentences
题目We are given two sentences A and B. (A sentence is a string of space separated words. Each word consists only of lowercase letters.)A word is uncommon if it appears exactly once in one of th...
2018-08-18 10:22:05 455
原创 LeetCode-Java-811. Subdomain Visit Count
题目A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the lowest level, "discuss.leetcod...
2018-08-18 09:44:27 314
原创 LeetCode-Java-876. Middle of the Linked List
题目Given a non-empty, singly linked list with head node head, return a middle node of linked list.If there are two middle nodes, return the second middle node.Example 1:Input: [1,2,3,4,5]O...
2018-08-02 10:02:40 395
中兴捧月-数字化婚姻配对尝试
2018-07-03
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人