原创 PAT 甲級 1035 Password (20分)

To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are a

原创 LeetCode MySQL 196. 刪除重複的電子郵箱

編寫一個 SQL 查詢,來刪除 Person 表中所有重複的電子郵箱,重複的郵箱裏只保留 Id 最小 的那個。 +----+------------------+ | Id | Email            | +----+----

原创 Leetcode 1162. 地圖分析(多源最短路)

你現在手裏有一份大小爲 N x N 的『地圖』(網格) grid,上面的每個『區域』(單元格)都用 0 和 1 標記好了。其中 0 代表海洋,1 代表陸地,你知道距離陸地區域最遠的海洋區域是是哪一個嗎?請返回該海洋區域到離它最近的陸地區域

原创 PAT 甲級 1065 A+B and C (64bit) (20分)

Given three integers A, B and C in [−2​^63​​,2^​63​​], you are supposed to tell whether A+B>C. Input Specification: The

原创 LeetCode 315. 計算右側小於當前元素的個數(樹狀數組)

給定一個整數數組 nums,按要求返回一個新數組 counts。數組 counts 有該性質: counts[i] 的值是  nums[i] 右側小於 nums[i] 的元素的數量。 示例:    輸入: [5,2,6,1]    輸出:

原创 PAT 甲級 1076 Forwards on Weibo (30分)

Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other

原创 Acwing 244. 謎一樣的牛

有n頭奶牛,已知它們的身高爲 1~n 且各不相同,但不知道每頭奶牛的具體身高。 現在這n頭奶牛站成一列,已知第i頭牛前面有Ai頭牛比它低,求每頭奶牛的身高。 輸入格式 第1行:輸入整數n。 第2..n行:每行輸入一個整數Ai,第i行表示第

原创 LeetCode 820. 單詞的壓縮編碼

給定一個單詞列表,我們將這個列表編碼成一個索引字符串 S 與一個索引列表 A。 例如,如果這個列表是 ["time", "me", "bell"],我們就可以將其表示爲 S = "time#bell#" 和 indexes = [0, 2

原创 算法基礎課get總結

#include<string.h> 1. memset(void *buffer, int c, int count) buffer:爲指針或是數組,c:是賦給buffer的值,count:是buffer的長度. mem

原创 PAT 甲級 1025 PAT Ranking (25分)

Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. E

原创 PAT 甲級 1031 Hello World for U (20分)

Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworl

原创 PAT 甲級 1057 Stack (30分)

Stack is one of the most fundamental data structures, which is based on the principle of Last In First Out (LIFO). The

原创 PAT 甲級 1054 The Dominant Color (20分)

Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each

原创 PAT 甲級 1078 Hashing (25分)

這道題考數據結構這門課的基本知識了 Hash解決衝突的方法: 線性探測法、平方探測法、拉鍊法 線性探查法: 先對一個素數m取餘結果爲d,得到想要放置的位置,但是這個位置可能已經被放置過了,如果被放置過了,就從d + 1每

原创 PAT 甲級 1024 Palindromic Number (25分)

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example,