
Leetcode
超悦人生
公众号【超悦编程】,专注于校招、算法、数据结构和计算机基础知识。
展开
-
LeetCode 458. Poor Pigs
LeetCode 458. Poor Pigs原创 2019-11-29 15:27:07 · 180 阅读 · 0 评论 -
LeetCode655.Print Binary Tree(java实现)
问题描述 Print a binary tree in an m*n 2D string array following these rules: The row number m should be equal to the height of the given binary tree. The column number n should always be an odd number....原创 2019-10-31 09:43:14 · 220 阅读 · 0 评论 -
LeetCode4. Median of Two Sorted Arrays(java实现)
问题描述 There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 ...原创 2019-10-25 23:56:20 · 126 阅读 · 0 评论 -
LeetCode25. Reverse Nodes in k-Group(每k个节点反转链表,java实现)
问题描述 k个一组反转链表。 解决方案 代码如下: //测试 public static void main(String[] args){ Node root = new Node(1); root.next = new Node(2); root.next.next = new Node(3); root.next.n...原创 2019-10-25 16:00:17 · 271 阅读 · 0 评论 -
leetcode.637 二叉树的层平均值(java实现)
问题描述 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 7 Output: [3, 14.5, 11] Exp...原创 2019-10-25 11:12:15 · 408 阅读 · 0 评论 -
LeetCode113. Path Sum II(java)
问题描述 Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum. Note: A leaf is a node with no children. Example: Given the below binary tree and sum = 22...原创 2019-10-25 10:37:54 · 194 阅读 · 0 评论 -
LeetCode867. Transpose Matrix(Java实现)
问题描述 Given a matrix A, return the transpose of A. The transpose of a matrix is the matrix flipped over it’s main diagonal, switching the row and column indices of the matrix. 解决方案 代码如下: public int...原创 2019-10-24 10:30:26 · 227 阅读 · 0 评论 -
LCP 5. 发 LeetCoin
力扣决定给一个刷题团队发LeetCoin作为奖励。同时,为了监控给大家发了多少LeetCoin,力扣有时候也会进行查询。原创 2019-09-27 10:48:56 · 648 阅读 · 1 评论 -
1201. Ugly Number III
LeetCode的第1201道题目:Write a program to find the n-th ugly number. Ugly numbers are positive integers which are divisible by a or b or c.原创 2019-09-23 11:20:44 · 622 阅读 · 0 评论 -
1202. Smallest String With Swaps
LeetCode的第1202道题目。You are given a string s, and an array of pairs of indices in the string pairs where pairs[i] = [a, b] indicates 2 indices(0-indexed) of the string.You can swap the characters at any pair of indices in the given pairs any number of time。原创 2019-09-23 11:06:14 · 480 阅读 · 0 评论 -
264.Ugly Number II
LeetCode的第264道题目,编写程序以查找第n个丑数。丑数是正数,其因数仅包括2, 3, 5。原创 2019-09-22 15:12:06 · 175 阅读 · 0 评论