随笔分类 -  Leetcode

1 2 3 4 5 ··· 7 下一页
摘要:You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following defin 阅读全文
posted @ 2020-11-16 00:24 琴影 阅读(367) 评论(0) 推荐(0) 编辑
摘要:Given the root of a binary tree, return the sum of every tree node's tilt. The tilt of a tree node is the absolute difference between the sum of all l 阅读全文
posted @ 2020-11-09 15:33 琴影 阅读(228) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers nums and an integer threshold, we will choose a positive integer divisor and divide all the array by it and sum the result 阅读全文
posted @ 2020-11-09 09:07 琴影 阅读(337) 评论(0) 推荐(0) 编辑
摘要:You are given a sorted unique integer array nums. Return the smallest sorted list of ranges that cover all the numbers in the array exactly. That is, 阅读全文
posted @ 2020-10-29 17:05 琴影 阅读(264) 评论(0) 推荐(0) 编辑
摘要: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. E 阅读全文
posted @ 2020-10-28 23:55 琴影 阅读(188) 评论(0) 推荐(0) 编辑
摘要:Alice and Bob take turns playing a game, with Alice starting first. Initially, there are n stones in a pile. On each player's turn, that player makes 阅读全文
posted @ 2020-10-28 23:53 琴影 阅读(274) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l 阅读全文
posted @ 2020-10-22 22:37 琴影 阅读(89) 评论(0) 推荐(0) 编辑
摘要:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word (last word means the last appea 阅读全文
posted @ 2020-09-16 21:31 琴影 阅读(176) 评论(0) 推荐(0) 编辑
摘要:Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->1->3 Output: 1->2->3->4 Example 2: Input: -1->5->3->4-> 阅读全文
posted @ 2020-09-14 09:21 琴影 阅读(168) 评论(0) 推荐(0) 编辑
摘要:You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time 阅读全文
posted @ 2020-09-12 10:40 琴影 阅读(210) 评论(0) 推荐(0) 编辑
摘要:Compare two version numbers version1 and version2.If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0. You may assume 阅读全文
posted @ 2020-09-09 21:39 琴影 阅读(174) 评论(0) 推荐(0) 编辑
摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the fo 阅读全文
posted @ 2020-06-28 23:00 琴影 阅读(265) 评论(0) 推荐(0) 编辑
摘要:The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 阅读全文
posted @ 2020-06-25 21:13 琴影 阅读(234) 评论(0) 推荐(0) 编辑
摘要:Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or 阅读全文
posted @ 2020-06-21 22:16 琴影 阅读(329) 评论(0) 推荐(0) 编辑
摘要: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 exist 阅读全文
posted @ 2020-06-07 23:34 琴影 阅读(341) 评论(0) 推荐(0) 编辑
摘要:Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, yo 阅读全文
posted @ 2020-06-05 11:15 琴影 阅读(252) 评论(0) 推荐(0) 编辑
摘要:Given a m * n matrix mat and an integer K, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for i - K <= r <= i + K 阅读全文
posted @ 2020-06-04 23:00 琴影 阅读(615) 评论(2) 推荐(0) 编辑
摘要:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Given linked list -- head = [4,5,1,9], wh 阅读全文
posted @ 2020-06-04 16:10 琴影 阅读(239) 评论(0) 推荐(0) 编辑
摘要:There are 2N people a company is planning to interview. The cost of flying the i-th person to city A is costs[i][0], and the cost of flying the i-th p 阅读全文
posted @ 2020-06-04 13:50 琴影 阅读(327) 评论(0) 推荐(0) 编辑

1 2 3 4 5 ··· 7 下一页