摘要: 题目描述: Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum o 阅读全文
posted @ 2018-08-31 10:32 gszzsg 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Given a collection of distinct integers, return all possible permutations. Example: 解题思路: 用回溯法。使用额外空间记录每个数值是否已经使用。 代码: 1 class Solution { 2 publ 阅读全文
posted @ 2018-08-30 17:48 gszzsg 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set 阅读全文
posted @ 2018-08-29 12:49 gszzsg 阅读(88) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Given a non-empty array of integers, return the k most frequent elements. Example 1: Example 2: Input: nums = [1], k = 1 Output: [1] Example 2: 阅读全文
posted @ 2018-08-28 11:09 gszzsg 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 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 [ 阅读全文
posted @ 2018-08-27 21:11 gszzsg 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Given a binary tree, return the inorder traversal of its nodes' values. Example: 解题思路: 递归的方法。 代码: 1 /** 2 * Definition for a binary tree node. 3 阅读全文
posted @ 2018-08-27 19:34 gszzsg 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes 阅读全文
posted @ 2018-08-26 20:14 gszzsg 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: Input: 3 / \ 9 20 / \ 15 阅读全文
posted @ 2018-08-22 20:58 gszzsg 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Example 2: Note: You may assume the tree (i.e., the given r 阅读全文
posted @ 2018-08-22 19:56 gszzsg 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 题目描述: You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for  阅读全文
posted @ 2018-08-19 20:10 gszzsg 阅读(77) 评论(0) 推荐(0) 编辑