自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(121)
  • 资源 (1)
  • 收藏
  • 关注

原创 29. Merge Sort Linked List

Given a singly-linked list, where each node contains an integer value, sort it in ascending order. The merge sort algorithm should be used to solve this problem.Examplesnull, is sorted to null 1 -> null, is sorted to 1 -> null 1 -> 2 -> 3

2021-09-18 16:16:40 245

原创 Problem 1 - Programming (Total 4)

Find all valid ways of putting N Queens on an N * N chessboard so that no two Queens can attack each other (two queens can attack each other if they are on the same row/column or same diagonal line).You can define your own way of how to print the soluti.

2021-07-30 06:09:10 217

原创 306. Check If Linked List Is Palindrome

Given a linked list, check whether it is a palindrome.Examples:Input: 1 -> 2 -> 3 -> 2 -> 1 -> nulloutput: true.Input: 1 -> 2-> 3-> null output: false.Requirements:Space complexity must be O(1)思路:找到中点,在reverse...

2021-07-14 16:53:19 140

原创 67. Top K Frequent Words

Given a composition with different kinds of words, return a list of the top K most frequent words in the composition.Assumptionsthe composition is not null and is not guaranteed to be sorted K >= 1andK could be larger than the number of distinct ..

2021-07-10 07:48:51 113

转载 [Java]面试: 如何实现一个不可变类(Immutable class)

https://blog.csdn.net/ToraNe/article/details/103003531

2021-07-08 13:20:22 117

原创 66. All Valid Permutations Of Parentheses I

Given N pairs of parentheses “()”, return a list with all the valid permutations.AssumptionsN > 0ExamplesN = 1, all valid permutations are ["()"] N = 3, all valid permutations are ["((()))", "(()())", "(())()", "()(())", "()()()"]思路:先有左括号,才有右括号

2021-07-01 09:05:08 165

原创 64. All Permutations I----DFS

Given a string with no duplicate characters, return a list with all permutations of the characters.Assume that input string is not null.ExamplesSet = “abc”, all permutations are [“abc”, “acb”, “bac”, “bca”, “cab”, “cba”]Set = "", all permutations a

2021-06-30 05:29:39 190

原创 25. K Smallest In Unsorted Array

Find the K smallest numbers in an unsorted integer array A. The returned numbers should be in ascending order.AssumptionsA is notnull K is >= 0 and smaller than or equal to size of AReturnan array with size K containing the K smallest numbers i.

2021-06-30 03:12:38 126

原创 Rainbow Sort

Given an array of balls, where the color of the balls can only be Red, Green or Blue, sort the balls such that all the Red balls are grouped on the left side, all the Green balls are grouped in the middle and all the Blue balls are grouped on the right sid

2021-06-29 09:57:36 152

原创 Quick Sort

Given an array of integers, sort the elements in the array in ascending order. The quicksort algorithm should be used to solve this problem.Examples{1} is sorted to {1} {1, 2, 3} is sorted to {1, 2, 3} {3, 2, 1} is sorted to {1, 2, 3} {4, 2, -3, 6,.

2021-06-28 12:54:45 102

原创 548. Bounded Random Number

Write a function that returns a random number within the range of [a, b] with equal probabilities.Note: you can use Java’s Random class.class Solution { public int random(int a, int b) { Random rand = new Random(); int i = a + rand.ne

2021-06-26 07:11:39 142

原创 552. Sum of Numbers in a Stack

Calculate the sum of all numbers in a Stack.Assumption: The Stack is not null or empty.Example:Stack contains 7,5,3,0Answer: 15class Solution { public int sumOfStack(Deque<Integer> stack) { int sum = stack.pop(); while (!s

2021-06-26 07:07:56 142

原创 551. Maximum Number in a Queue

Given a queue of integers, find the maximum number in it.Assumption: the queue is not null or empty.Example:Queue contains 5,8,3,2,7Answer: 8.class Solution { public int maxInQueue(Queue<Integer> queue) { int max = queue.poll();

2021-06-26 07:03:00 80

原创 9. Palindrome Number

Given an integerx, returntrueifxis palindrome integer.An integer is apalindromewhen it reads the same backward as forward. For example,121is palindrome while123is not.Example 1:Input: x = 121Output: trueExample 2:Input: x = -121...

2021-03-12 19:39:15 69

原创 13. Roman to Integer

Roman numerals are represented by seven different symbols:I,V,X,L,C,DandM.Symbol ValueI 1V 5X 10L 50C 100D 500M 1000For example,2is written asI...

2021-03-12 19:34:13 72

原创 1225. Report Contiguous Dates----判断连续日期

Table:Failed+--------------+---------+| Column Name | Type |+--------------+---------+| fail_date | date |+--------------+---------+Primary key for this table is fail_date.Failed table contains the days of failed tasks.Table:Succeed..

2020-10-09 15:01:29 684

原创 1285. Find the Start and End Number of Continuous Ranges----判断连续数字

Table:Logs+---------------+---------+| Column Name | Type |+---------------+---------+| log_id | int |+---------------+---------+id is the primary key for this table.Each row of this table contains the ID in a log Table.Sinc...

2020-10-03 05:35:06 541

翻译 1321. Restaurant Growth----利用窗口函数连续几天累加求和和均值(BETWEEN 6 PRECEDING AND CURRENT ROW)

Table:Customer+---------------+---------+| Column Name | Type |+---------------+---------+| customer_id | int || name | varchar || visited_on | date || amount | int |+---------------+---------+(customer_id, .

2020-10-03 03:06:30 414

原创 1459. Rectangles Area----同列数据相减

Table:Points+---------------+---------+| Column Name | Type |+---------------+---------+| id | int || x_value | int || y_value | int |+---------------+---------+id is the primary key for this table.Each p.

2020-10-01 08:04:38 282

原创 1501. Countries You Can Safely Invest In----取一个字符串左边N个字母 left(string, N)

TablePerson:+----------------+---------+| Column Name | Type |+----------------+---------+| id | int || name | varchar || phone_number | varchar |+----------------+---------+id is the primary key for this table..

2020-09-30 15:04:17 279

原创 1527. Patients With a Condition----字母选择 like %...%

Table:Patients+--------------+---------+| Column Name | Type |+--------------+---------+| patient_id | int || patient_name | varchar || conditions | varchar |+--------------+---------+patient_id is the primary key for this table.'co.

2020-09-30 07:22:03 294

原创 1543. Fix Product Name Format----去掉字符串空格trim()

Table:Sales+--------------+---------+| Column Name | Type |+--------------+---------+| sale_id | int || product_name | varchar || sale_date | date |+--------------+---------+sale_id is the primary key for this table.Each row .

2020-09-30 02:44:51 137

原创 1107. New Users Daily Count----通过min()选择分组中的第一条数据

Table:Traffic+---------------+---------+| Column Name | Type |+---------------+---------+| user_id | int || activity | enum || activity_date | date |+---------------+---------+There is no primary key for this table, it .

2020-09-28 14:56:11 282

原创 1435. Create a Session Bar Chart----case when

Table:Sessions+---------------------+---------+| Column Name | Type |+---------------------+---------+| session_id | int || duration | int |+---------------------+---------+session_id is the primary key for .

2020-09-26 08:56:32 609

原创 1204. Last Person to Fit in the Elevator----参考No.534 窗口函数累计求和

Table:Queue+-------------+---------+| Column Name | Type |+-------------+---------+| person_id | int || person_name | varchar || weight | int || turn | int |+-------------+---------+person_id is the primary key colu.

2020-09-25 16:38:00 105

原创 1158. Market Analysis I

Table:Users+----------------+---------+| Column Name | Type |+----------------+---------+| user_id | int || join_date | date || favorite_brand | varchar |+----------------+---------+user_id is the primary key of this tab.

2020-09-25 13:27:13 124

原创 1164. Product Price at a Given Date----union /case when + null

Table:Products+---------------+---------+| Column Name | Type |+---------------+---------+| product_id | int || new_price | int || change_date | date |+---------------+---------+(product_id, change_date) is the primary k.

2020-09-24 15:33:09 203

原创 1174. Immediate Food Delivery II----row_number()/first_value(), case when

Table:Delivery+-----------------------------+---------+| Column Name | Type |+-----------------------------+---------+| delivery_id | int || customer_id | int || order_date .

2020-09-24 14:53:36 224

原创 1050. Actors and Directors Who Cooperated At Least Three Times----count() 可以放在having后面

Table:ActorDirector+-------------+---------+| Column Name | Type |+-------------+---------+| actor_id | int || director_id | int || timestamp | int |+-------------+---------+timestamp is the primary key column for this table..

2020-09-24 13:11:55 317

原创 534. Game Play Analysis III----window function sum() over partition by 统计分组累加的和

Table:Activity+--------------+---------+| Column Name | Type |+--------------+---------+| player_id | int || device_id | int || event_date | date || games_played | int |+--------------+---------+(player_id, event_date.

2020-09-24 06:56:16 187

原创 1084. Sales Analysis III----not between

Table:Product+--------------+---------+| Column Name | Type |+--------------+---------+| product_id | int || product_name | varchar || unit_price | int |+--------------+---------+product_id is the primary key of this table.Tab.

2020-09-23 15:35:19 112

原创 1194. Tournament Winners---取每组中的最大值所在的记录

Table:Players+-------------+-------+| Column Name | Type |+-------------+-------+| player_id | int || group_id | int |+-------------+-------+player_id is the primary key of this table.Each row of this table indicates the group of each .

2020-09-23 08:23:57 247

原创 1341. Movie Rating----union使用

Table:Movies+---------------+---------+| Column Name | Type |+---------------+---------+| movie_id | int || title | varchar |+---------------+---------+movie_id is the primary key for this table.title is the name of the mov.

2020-09-19 14:19:26 366

原创 1479. Sales by Day of the Week----case when条件检查

Table:Orders+---------------+---------+| Column Name | Type |+---------------+---------+| order_id | int || customer_id | int || order_date | date | | item_id | varchar || quantity | int |+--------------.

2020-09-19 08:09:06 145

原创 1445. Apples & Oranges----两者求差

Table:Sales+---------------+---------+| Column Name | Type |+---------------+---------+| sale_date | date || fruit | enum | | sold_num | int | +---------------+---------+(sale_date,fruit) is the primary key for th.

2020-09-19 08:02:44 265

转载 日期,ifnull等用法

MySql 里的IFNULL、NULLIF和ISNULL用法MySQL 日期与时间方面的函数

2020-09-18 08:59:07 358

原创 1454. Active Users----dense_rank()排序

TableAccounts:+---------------+---------+| Column Name | Type |+---------------+---------+| id | int || name | varchar |+---------------+---------+the id is the primary key for this table.This table contains the acco.

2020-09-17 17:12:54 429

原创 1127. User Purchase Platform----分组统计,通过产生新的join table来统计不存在的字段组合

Table:Spending+-------------+---------+| Column Name | Type |+-------------+---------+| user_id | int || spend_date | date || platform | enum | | amount | int |+-------------+---------+The table logs the spendings .

2020-09-17 16:36:06 247

原创 569. Median Employee Salary----通过分组排序来判断中位数

TheEmployeetable holds all employees. The employee table has three columns: Employee Id, Company Name, and Salary.+-----+------------+--------+|Id | Company | Salary |+-----+------------+--------+|1 | A | 2341 ||2 | A ..

2020-09-17 06:56:41 417

原创 1384. Total Sales Amount by Year----取日期中的年份year()和计算日期之间的差别datediff()

Table:Product+---------------+---------+| Column Name | Type |+---------------+---------+| product_id | int || product_name | varchar |+---------------+---------+product_id is the primary key for this table.product_name is the name .

2020-09-15 17:19:58 518

现代模式识别 国防科技大学 出版

模式识别的经典教材 非常详细地介绍了各类模式识别的方法

2009-03-08

空空如也

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

TA关注的人

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