[LeetCode] Exchange Seats
SELECT
m.id
,
IFNULL(IF ( ( m.id & 0x1 ) = 1,r1.student, r2.student ),m.student) AS 'Student'
FROM
seat m
LEFT JOIN
seat r1
ON
r1.id = (m.id+1)
LEFT JOIN
seat r2
ON
r2.id = (m.id-1)
ORDER
BY id
Runtime: 166 ms, faster than 58.92% of MySQL online submissions for Exchange Seats.
------------------------------------------------------------------------
似乎不好,但簡單的寫法,歡迎大家流言討論,讓你我更好。
留言
張貼留言