题目如下: Given a binary tree, return the sum of values of nodes with even-valued grandparent. (A grandparent of a node is the parent of its parent, if it ...
分类:
其他好文 时间:
2020-01-12 17:53:44
阅读次数:
56
import java.util.ArrayList; import java.util.List; /** * Given an array nums of n integers and an integer target, are there elements * a, b, c, and d ...
分类:
其他好文 时间:
2020-01-12 15:29:51
阅读次数:
121
import java.util.ArrayList; import java.util.LinkedList; import java.util.List; /* * Given a string containing digits from 2-9 inclusive, return all p ...
分类:
其他好文 时间:
2020-01-12 15:05:05
阅读次数:
91
二叉树的路径和。题意是给一个二叉树和一个数字sum。求是否有这样一条路径可以使得二叉树从根节点到叶子节点经过的所有的节点值之和等于sum。此题可以用BFS和DFS两种做法解决,时间和空间复杂度都是O(n)。例子如下, Example: Given the below binary tree and ...
分类:
其他好文 时间:
2020-01-12 15:04:09
阅读次数:
65
二叉树的路径和二。题意跟版本一很接近,唯一的不同是版本一只是问是否有满足条件的路径;版本二是输出所有满足条件的路径和。例子, Example: Given the below binary tree and sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ / \ 7 2 ...
分类:
其他好文 时间:
2020-01-12 14:56:50
阅读次数:
47
Given an array A of integers and integer K, return the maximum S such that there exists i < j with A[i] + A[j] = S and S < K. If no i, j exist satisfy ...
分类:
其他好文 时间:
2020-01-12 11:53:41
阅读次数:
79
Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number m ...
分类:
其他好文 时间:
2020-01-12 09:53:56
阅读次数:
64
题目: Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: "tree" Output: "eert" Explanation: 'e' appears ...
分类:
编程语言 时间:
2020-01-12 09:51:15
阅读次数:
93
二叉树层序遍历。题干既是题意。如下例子, For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its level order traversal as: [ [3], [9,20], [1 ...
分类:
其他好文 时间:
2020-01-12 09:41:11
阅读次数:
54
Question Given an array of citations sorted in ascending order (each citation is a non-negative integer) of a researcher, write a function to compute ...
分类:
其他好文 时间:
2020-01-10 00:53:46
阅读次数:
74