classSolution{public:stringcompressString(stringS){int i=0,j=0;int n=S.size();string tmp;// 「外层循环」i 指向每个首次出现的字符while(i<n){// 「内层循环」j 向前遍历,直到字符串末尾或找到与 s[i] 不同的字符时跳出while(j<n&&S[i]==S[j])j++;// 压缩字符串,添加至 tmptmp+=S[i]...
Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be anysubsequence of the other strings. A subsequence is ...
Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other. Given an integern, return all distinct solutions to then-queens puzzle. Each solution contains a distinct board configuration of then-queens' placement, where'Q'and'.'both indicat...
0218 The Skyline Problem Go 34.5% Hard 0219 Contains Duplicate II Go 37.7% Easy 0220 Contains Duplicate III Go 20.9% Medium 0221 Maximal Square 37.7% Medium 0222 Count Complete Tree Nodes Go 46.7% Medium 0223 Rectangle Area Go 37.8% Medium 0224 Basic Calculator Go 36.8% Hard 0225...
This problem was inspired by this original tweet by Max Howell: Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck off. 【解答】这个段子已经在互联网上广为流传了,实际事情的背景我们不得而知。不过如果真是...
0218 The Skyline Problem Go 34.5% Hard 0219 Contains Duplicate II Go 37.7% Easy 0220 Contains Duplicate III Go 20.9% Medium 0221 Maximal Square 37.7% Medium 0222 Count Complete Tree Nodes Go 46.7% Medium 0223 Rectangle Area Go 37.8% Medium 0224 Basic Calculator Go 36.8% Hard 0225...
Interesting problem, here is my take on it: ParkingSlot > Floor > Parking And separate FareController So, a Parking can have many Floors and Floor and can have many ParkingSlots. Each Parking Slot is of certain slot size. Vehicle is the interface type and all Vehicles just have to impleme...
Free Ice Cream 水题 A. Free Ice Cream 题目连接: http://www.codeforces.com/contest/686/problem/A Description After their adventure with the magic mirror Kay and Gerda have returned home and sometimes give free ice cream to ki...codeforces 804B——Ice cream coloring(图论,dfs,数据结构,好...
Kids With the Greatest Number of Candies Kth Ancestor of a Tree Node Kth Missing Positive Number Kth Smallest Element in a BST LICENSE LRU Cache Largest Divisible Subset Largest Rectangle in Histogram Largest Time for Given Digits Solution Last Moment Before All Ants Fall Out of a...
('$' means the problem is locked on Leetcode, '*' means the problem is related to Database, '#' means the problem is related to Shell, '~' means the concurrency problems.) #TitleSolutionDifficulty 1352 Product of the Last K Numbers 50.20% Medium 1351 Count Negative Numbers in a Sorted...