自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(252)
  • 问答 (1)
  • 收藏
  • 关注

原创 Plant Location

思路:使用二分法,但是要用两个3等分点。

2023-04-09 01:49:55 443

原创 Chef and Easy Problem

这是codechef解题笔记的第一篇文章,强烈建议在校学生在codechef上刷题练习~

2023-04-08 02:39:32 205

原创 Leetcode 跳跃游戏

5. 跳跃游戏5给你一个整数数组arr 和一个整数d 。每一步你可以从下标i跳到:i + x,其中i + x < arr.length且0 < x <= d。i - x,其中i - x >= 0且0 < x <= d。除此以外,你从下标i 跳到下标 j需要满足:arr[i] > arr[j]且 arr[i] > arr[k],其中下标k是所有 i到 j之间的数字(更正式的,min(i, j) < k...

2020-10-04 16:28:46 250

原创 leectode 石子游戏

1. 石子游戏题目描述:Alex and Lee play a game with piles of stones. There are an even number ofpilesarranged in a row, and each pile has a positive integer number of stonespiles[i].The objective of the game is to end with the moststones. The total numbe...

2020-08-24 02:00:13 492

原创 Leetcode 第32场双周赛

只做出3道题,记录一下代码~5468.第 k 个缺失的正整数给你一个严格升序排列的正整数数组arr和一个整数k。请你找到这个数组里第k个缺失的正整数。示例 1:输入:arr = [2,3,4,7,11], k = 5输出:9解释:缺失的正整数包括 [1,5,6,8,9,10,12,13,...] 。第 5 个缺失的正整数为 9 。示例 2:输入:arr = [1,2,3,4], k = 2输出:6解释:缺失的正整数包括 [5,6,7,...] 。第...

2020-08-09 00:45:13 304

原创 牛客编程巅峰赛S1-9

A. 牛牛的字符反转题目描述:牛牛酷爱循环右移操作,但是牛牛的电脑寄存器坏掉了,无法实现正常的循环右移操作,只能实现区间反转操作,现在牛牛有一个长度为n的字符串,他想进行循环右移k位的操作,你能告诉牛牛,他最少对这个字符串进行几次区间反转操作能实现循环右移k位呢。反转操作指字符串某一区间[L,R]内的字符反转,例如“123456”,区间[3,5]进行反转字符串变为“125436”。假设字符串每一位都不同。给定一个字符串长度n和循环右移次数k,求最少反转次数。思路: 找规律.程序:cla

2020-08-07 11:41:53 217

原创 Leetcode 周赛186

1.分割字符串的最大得分题目描述:给你一个由若干 0 和 1 组成的字符串 s ,请你计算并返回将该字符串分割成两个 非空 子字符串(即左 子字符串和 右 子字符串)所能获得的最大得分。「分割字符串的得分」为 左 子字符串中 0 的数量加上 右 子字符串中 1 的数量。示例 1:输入:s = "011101"输出:5解释:将字符串 s 划分为两个非空子字符串的...

2020-04-26 18:04:43 374

原创 Leetcode 93. Restore IP Addresses

题目描述:Given a string containing only digits, restore it by returning all possible valid IP address combinations.Example:Input: "25525511135"Output: ["255.255.11.135", "255.255.111.35"]程序:c...

2020-04-20 23:42:34 170 1

原创 Leetcode 252.Contiguous Array

题目描述:Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.Example 1:Input: [0,1]Output: 2Explanation: [0, 1] is the longest contiguous subarray ...

2020-04-20 17:19:34 182

原创 LeetCode 183周赛

5376. Minimum Subsequence in Non-Increasing Order题目描述:Given the array nums, obtain a subsequence of the array whose sum of elements is strictly greater than the sum of the nonincluded elements in...

2020-04-05 14:37:59 298 1

原创 42. Trapping Rain Water

题意描述:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.The above elevation map is represented b...

2020-04-04 11:10:57 184

原创 Leetcode周赛180

1380.Lucky Numbers in a MatrixGiven am * nmatrix ofdistinctnumbers, return all lucky numbers in thematrix inanyorder.A lucky number is an element of the matrix such that it is the minim...

2020-03-22 21:12:06 287

原创 137. Single Number II

题目描述:Given anon-emptyarray of integers, every element appearsthreetimes except for one, which appears exactly once. Find that single one.Note:Your algorithm should have a linear runtime comp...

2020-03-03 01:06:11 164

原创 40. Combination Sum II

题目描述:Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations incandidateswhere the candidate numbers sums totarget.Each number incandida...

2020-01-03 22:26:14 135

原创 114. Flatten Binary Tree to Linked List

题目描述:Given a binary tree, flatten it to a linked list in-place.For example, given the following tree: 1 / \ 2 5 / \ \3 4 6The flattened tree should look like:1 \ 2...

2019-12-31 01:52:08 179

原创 113. Path Sum II

题目: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 andsum = 2...

2019-12-06 00:05:41 179

原创 129. Sum Root to Leaf Numbers

题目:;Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which represents the number123.Find th...

2019-12-05 00:56:35 155

原创 501. Find Mode in Binary Search Tree

题目描述:Given a binary search tree (BST) with duplicates, find all themode(s)(the most frequently occurred element) in the given BST.Assume a BST is defined as follows:The left subtree of a node ...

2019-11-29 01:07:42 200

原创 543. Diameter of Binary Tree

题目描述:Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of thelongestpath between any two nodes in a tree. This path may o...

2019-11-27 01:13:47 162

原创 326. Power of Three

题目描述:Given an integer, write a function to determine if it is a power of three.Example 1:Input: 27Output: trueExample 2:Input: 0Output: falseExample 3:Input: 9Output: trueExampl...

2019-10-27 23:30:40 126

原创 257. Binary Tree Paths

题目描述:Given a binary tree, return all root-to-leaf paths.Note:A leaf is a node with no children.Example:Input: 1 / \2 3 \ 5Output: ["1->2->5", "1->3"]Explanation: ...

2019-10-20 18:01:11 130

原创 205. Isomorphic Strings

题目描述:Given two stringssandt, determine if they are isomorphic.Two strings are isomorphic if the characters inscan be replaced to gett.All occurrences of a character must be replaced with a...

2019-10-17 00:25:11 176

原创 203. Remove Linked List Elements

题目描述:Remove all elements from a linked list of integers that have valueval.Example:Input: 1->2->6->3->4->5->6, val = 6Output: 1->2->3->4->5程序:class Solutio...

2019-10-16 23:55:27 123

原创 190. Reverse Bits

题目描述:Reverse bits of a given 32 bits unsigned integer.Example 1:Input: 00000010100101000001111010011100Output: 00111001011110000010100101000000Explanation: The input binary string 00000010...

2019-10-15 11:11:41 131

转载 189. Rotate Array

题目描述:Given an array, rotate the array to the right byksteps, wherekis non-negative.Example 1:Input: [1,2,3,4,5,6,7] and k = 3Output: [5,6,7,1,2,3,4]Explanation:rotate 1 steps to the righ...

2019-10-14 11:06:04 113

原创 169. Majority Element

题目描述:Given an array of sizen, find the majority element. The majority element is the element that appearsmore than⌊ n/2 ⌋times.You may assume that the array is non-empty and the majority eleme...

2019-10-12 12:41:00 121

原创 168. Excel Sheet Column Title

题目描述:Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA ...

2019-10-12 12:35:49 115

原创 160. Intersection of Two Linked Lists

题目描述:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:begin to intersect at node c1.Example 1:...

2019-10-11 11:28:28 199

原创 141. Linked List Cycle

题目描述:Given a linked list, determine if it has a cycle in it.To represent a cycle in the given linked list, we use an integerposwhich represents the position (0-indexed)in the linked list where ...

2019-10-07 10:23:29 154

原创 136. Single Number

题目描述:Given anon-emptyarray of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it wit...

2019-10-07 09:55:26 118

原创 88. Merge Sorted Array

题目描述:Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:The number of elements initialized innums1andnums2aremandnrespectively. You may ass...

2019-10-05 00:35:05 118

原创 83. Remove Duplicates from Sorted List

题目描述:Given a sorted linked list, delete all duplicates such that each element appear onlyonce.Example 1:Input: 1->1->2Output: 1->2Example 2:Input: 1->1->2->3->3Out...

2019-10-04 00:14:02 113

原创 66. Plus One

题目描述:Given anon-emptyarray of digitsrepresenting a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each ...

2019-10-04 00:01:50 125

原创 54. Spiral Matrix

题目描述:Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.Example 1:Input:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]Output: [1,2,3,6,9,8,7...

2019-10-03 00:28:33 146

原创 48. Rotate Image

题目描述:You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the imagein-place, which means you have to modify the input 2D m...

2019-09-30 00:34:03 124

原创 tensorflow的API(1)

1. 张量变换 Casting tf.string_to_number(string_tensor, out_type=None, name=None)'''将输入张量的每个字符转换成指定的数据类型(int32溢出会导致错误,而float溢出会导致取整。)参数: string_tensor...

2019-09-27 21:24:39 175

原创 41. First Missing Positive

题目描述:Given an unsorted integer array, find the smallest missingpositive integer.Example 1:Input: [1,2,0]Output: 3Example 2:Input: [3,4,-1,1]Output: 2Example 3:Input: [7,8,9,11,12...

2019-09-27 00:37:03 124

原创 34. Find First and Last Position of Element in Sorted Array

题目描述:Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If...

2019-09-26 00:47:47 106

原创 33. Search in Rotated Sorted Array

题目描述:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e.,[0,1,2,4,5,6,7]might become[4,5,6,7,0,1,2]).You are given a target value to search. If...

2019-09-15 22:10:38 128

原创 24. Swap Nodes in Pairs

题目描述:Given alinked list, swap every two adjacent nodes and return its head.You may not modify the values in the list's nodes, only nodes itself may be changed.Example:Given 1->2->3-&...

2019-09-03 23:55:51 119

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除