博客 / 列表

愛吃飯的程序媛 - 1235. Maximum Profit in Job Scheduling

題目 We havenjobs, where every jobis scheduled to be done fromstartTime[i]toendTime[i], obtaining a profitofprofit[i]. You're given thestartTime,endTimeandprofitarrays,you need to output

狀態轉移 , yyds乾貨盤點 , i++ , Time , 代碼人生

愛吃飯的程序媛 - 1217. Minimum Cost to Move Chips to The Same Position

題目 There are some chips, and the i-th chip is at positionchips[i]. You can perform any of the two following types of movesany number of times(possiblyzero)on any chip: Move thei

數組 , yyds乾貨盤點 , 代碼人生

愛吃飯的程序媛 - 1207. Unique Number of Occurrences

題目 Given an array of integersarr,write a function that returnstrueif and only if the number of occurrences of each value in the array is unique. Example 1: Input: arr = [1,2,2,1

數組 , yyds乾貨盤點 , 代碼人生

愛吃飯的程序媛 - 1170. Compare Strings by Frequency of the Smallest Character

題目 Let's define a functionf(s)over a non-empty strings, which calculates the frequency of the smallest character ins. For example,ifs = "dcce"thenf(s) = 2because the smallest character is"

數組 , yyds乾貨盤點 , i++ , 代碼人生 , 字典序

愛吃飯的程序媛 - 1145. Binary Tree Coloring Game

題目 Two players play a turn based game on a binary tree. We are giventherootof this binary tree, and the number of nodesnin the tree.nis odd, andeach node has a distinct value from1ton.

結點 , yyds乾貨盤點 , 連通分量 , 代碼人生 , 二叉樹

愛吃飯的程序媛 - 1137. N-th Tribonacci Number

題目 The Tribonacci sequence Tnis defined as follows: T0= 0, T1= 1, T2= 1, and Tn+3= Tn+ Tn+1+ Tn+2for n = 0. Givenn, return the value of Tn. Example 1: Input: n = 4 Output:

yyds乾貨盤點 , 代碼人生 , ci

愛吃飯的程序媛 - 1108. Defanging an IP Address

題目 Given a valid (IPv4) IPaddress, return a defanged version of that IP address. AdefangedIP addressreplaces every period"."with"[.]". Example 1: Input: address = "1.1.1.1" O

yyds乾貨盤點 , ip , 代碼人生

愛吃飯的程序媛 - 1089. Duplicate Zeros

題目 Given a fixed lengtharrayarrof integers, duplicate each occurrence of zero, shifting the remaining elements to the right. Note that elements beyond the length of the original array a

數組 , yyds乾貨盤點 , i++ , 數組長度 , 代碼人生

愛吃飯的程序媛 - 1074. Number of Submatrices That Sum to Target

題目 Given amatrix, and atarget, return the number of non-empty submatrices that sum totarget. A submatrixx1, y1, x2, y2is the set of all cellsmatrix[y]withx1 = x = x2andy1 = y = y2. T

時間複雜度 , yyds乾貨盤點 , i++ , 暴力解法 , 代碼人生

愛吃飯的程序媛 - 1048. Longest String Chain

題目 Given a list of words, each word consists of English lowercase letters. Let's sayword1is a predecessor ofword2if and only if we can add exactly one letter anywhere inword1to make it

yyds乾貨盤點 , 字符串 , 遞推 , bc , 代碼人生

愛吃飯的程序媛 - 1038. Binary Search Tree to Greater Sum Tree

題目 Given therootof 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 of all keys greater than the ori

yyds乾貨盤點 , 二叉搜索樹 , 代碼人生 , 子樹 , go

愛吃飯的程序媛 - 1037. Valid Boomerang

題目 Aboomerangis a set of 3 points that are all distinct andnotin a straight line. Given a listof three points in the plane, return whether these points are a boomerang. Example 1:

yyds乾貨盤點 , 斜率 , 代碼人生

愛吃飯的程序媛 - 1028. Recover a Tree From Preorder Traversal

題目 We run apreorderdepth first search on therootof a binary tree. At each node in this traversal, we outputDdashes (whereDis thedepthof this node), then we output the value of this node

yyds乾貨盤點 , 字符串 , 代碼人生 , 子節點 , Git

愛吃飯的程序媛 - 1019. Next Greater Node In Linked List

題目 We are given a linked list with head as the first node. Let's number the nodes in the list: node\_1, node\_2, node\_3, ... etc. Each node may have a next larger value: for node_i, ne

結點 , 單調棧 , yyds乾貨盤點 , 鏈表 , 代碼人生

愛吃飯的程序媛 - 1018. Binary Prefix Divisible By 5

題目 Given an arrayAof0s and1s, considerN_i: the i-th subarray fromA[0]toA[i]interpretedas a binary number (from most-significant-bit to least-significant-bit.) Return a list of booleansa

數組 , yyds乾貨盤點 , 代碼人生 , 有效位 , 二進制數

愛吃飯的程序媛 - 1011. Capacity To Ship Packages Within D Days

題目 A conveyor belt has1 packages that must be shipped from one port to another withinDdays. Thei-th package on the conveyor belt has a weight ofweights[i]. Each day, we load the ship wi

4th , 數組 , yyds乾貨盤點 , 代碼人生 , ci

愛吃飯的程序媛 - 1005. Maximize Sum Of Array After K Negations

題目 Given an array A of integers, we must modify the array in the following way: we choose an i and replace A[i] with -A[i], and we repeat this process K times in total. (We may choose the

數組 , yyds乾貨盤點 , 最小值 , 最小堆 , 代碼人生

愛吃飯的程序媛 - 1003. Check If Word Is Valid After Substitutions

題目 We are given that the string "abc" is valid. From any valid string V, we may split V into two pieces X and Y such that X + Y (X concatenated with Y) is equal to V. (X or Y may be emp

yyds乾貨盤點 , 字符串 , bc , 代碼人生 , 括號匹配

愛吃飯的程序媛 - 992. Subarrays with K Different Integers

題目 Given an array A of positive integers, call a (contiguous, not necessarily distinct) subarray of A good if the number of different integers in that subarray is exactly K. (For exampl

數組 , yyds乾貨盤點 , 滑動窗口 , 代碼人生 , ide

愛吃飯的程序媛 - 990. Satisfiability of Equality Equations

題目 Given an arrayequationsof strings that represent relationships between variables, each stringequations[i]has length4and takes one of two different forms:"a==b"or"a!=b". Here,aandbare lo

數組 , yyds乾貨盤點 , 字符串 , 變量名 , 代碼人生

愛吃飯的程序媛 - 977. Squares of a Sorted Array

題目 Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order. Example 1: Input: [-4,-1,0,3,10] Output: [0,1,9,16

指針移動 , 數組 , yyds乾貨盤點 , 最小值 , 代碼人生