832. Flipping an Image (5月22日 )
解答
class Solution {
public:
vector<vector<int>> flipAndInvertImage(vector<vector<int>>& A) {
for(auto it1=A.begin();it1!=A.end();++it1){
vector<int> & v_temp=*it1;
reverse(v_temp.begin(),v_temp.end());
for(int it2=0 ;it2!=A.size();++it2){
v_temp[it2] = (v_temp[it2]+1)%2;
}
}
return A;
}
};
筆記
- vector二維數組的使用
- v_temp要傳遞引用才能修改值
- 將0變1,1變0的方法
832. Flipping an Image (5月22日 )
相關推薦
832. Flipping an Image (5月22日 )
div cpp ID solution 方法 and for return amp 解答 class Solution { public: vector<vector<int>> flipAndInvertImage(vector<ve
Leetcode#832. Flipping an Image(翻轉圖像)
void 結果 遍歷 ack 矩陣 意思 全部 ++ int 題目描述 給定一個二進制矩陣 A,我們想先水平翻轉圖像,然後反轉圖像並返回結果。 水平翻轉圖片就是將圖片的每一行都進行翻轉,即逆序。例如,水平翻轉 [1, 1, 0] 的結果是 [0, 1, 1]。 反轉圖片的意
【python3】leetcode 832. Flipping an Image(easy)
832. Flipping an Image(easy) Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulti
leetcode 832 Flipping an Image(反轉影象) python3 最簡程式碼(一行程式碼)
class Solution: def flipAndInvertImage(self, A): """ :type A: List[List[int]]
二周第五次課(12月22日)
數據庫 類型 whereis path spa 七天 環境變量path tar 實例 二周第五次課(12月22日)2.23/find命令2.24/find命令2.25/ find命令2.26 文件名後綴 其他搜索文件命令: · which搜索文件是從環境變量PATH裏找
七周一次課(1月22日)
查看 load swap 服務 系統 cto 運行 用戶 oss 七周一次課(1月22日)10.1 使用w查看系統負載w直接在終端登陸的 用戶TTYload average 系統負載 1分鐘 5分鐘 15分鐘 系統負載 單位時間內使用cpu活動的進程平均個數 cpu是
一周第一次課筆記(1月22日)
終端 想要 alt 一次 鏡像 linux 一個 images bsp 一周第一次課(1月22日)1.1學習之初1.2約定1.3認識Linux1.4安裝虛擬機1.5安裝centos7 1.1學習之初 學習之前合理定位自己 給自己設定1個合理目標 計劃好學習的期限
一周第四次課(3月22日)
單用戶1.13 單用戶模式 重啟有以下命令: rebootinit 6shutdown -r now立即重啟shutdown -r通知後重啟 關機命令init 0poweroffhaltshutdown -h now立即關機shutdown -h通知用戶並1分鐘後關機 ctrl + X
linux七周四次課(3月22日)
linux 筆記 七周四次課(3月22日)10.15 iptables filter表案例10.16/10.17/10.18 iptables nat表應用 擴展 iptables應用在一個網段 http://www.aminglinux.com/bbs/thread-177-1-1.html s
Linux20180502 六周第四次課(5月2日)
sed 練習 六周第四次課(5月2日)復習 擴展打印某行到某行之間的內容http://ask.apelearn.com/question/559 sed轉換大小寫 http://ask.apelearn.com/question/7758 sed在某一行最後添加一個數字http://ask.apelearn.
Linux20180503 六周第五次課(5月3日)awk擴展
awk 六周第五次課(5月3日)復習擴展awk 中使用外部shell變量http://ask.apelearn.com/question/199 相對來說,awk更像是一種簡單的編程語言 A=44echo "ABCD" | awk -v GET_A=$A ’{print GET_A}’說明
LiNUX20180509七周四次課(5月9日)IPTABLES
iptables nat七周四次課(5月9日)10.15 iptables filter表案例10.16/10.17/10.18 iptables nat表應用擴展1. iptables應用在一個網段 http://www.aminglinux.com/bbs/thread-177-1-1.html2. sa
Linux學習筆記十四周一次課(5月9日)
NFS介紹 NFS服務端安裝 NFS客戶端安裝 14.1 NFS介紹14.2 NFS服務端安裝配置服務端安裝nfs-utils和rpcbind;客戶端只安裝nfs-utils#yum install -y nfs-utils rpcbind#vim /etc/exports /home/nfste
Linux學習筆記十四周二次課(5月10日)
exportfs NFS客戶端問題 FTP vsftpd搭建ftp 14.4 exportfs命令#exportfs -arv //重新掛載#vim /etc/exports/tmp/192.168.133.0/24(rw,sync,no_root_squash)14.5 NFS客戶端問題#m
linux十四周四次課(5月14日)
linux 筆記 十四周四次課(5月14日)16.1 Tomcat介紹16.2 安裝jdk16.3 安裝Tomcat 16.1 Tomcat介紹 16.2 安裝jdk 打開下載網址。 點擊jdk=8u144-linux-x64.tar.gz ,下載 傳到linux ctrl+F打開xftp 把下載的文
811. Subdomain Visit Count (5月23日)
sys 有符號 using pan bstr leet double類型 sim clas 解答 class Solution { public: vector<string> subdomainVisits(vector<string>&a
500. Keyboard Row (5月26日)
() tor push_back str DC Go row ons OS 解答 class Solution { public: vector<string> findWords(vector<string>& words) {
840. Magic Squares In Grid (5月27日)
() || 二次 邏輯 優先 pla sub 分析 flag 開頭 這是每周比賽中的第一道題,博主試了好幾次坑後才勉強做對了,第二道題寫的差不多結果去試時結果比賽已經已經結束了(尷尬),所以今天只記錄第一道題吧 題目原文 Magic Squares In Grid A
463. Island Perimeter (5月29日)
amp lan clas num size sla 只需要 ++ PE 解答 class Solution { public: int islandPerimeter(vector<vector<int>>& grid) {
AWSome Day廣州(5月11日)等你來! – 運維派
2017上半年 AWSome Day收官站 廣州開啟! AWS傾情出品 Amazon Web Services (AWS) 誠摯邀請您,參加2017年AWSome Day雲端計算免費培訓。 在2017上半年,本活動將在廣州收官 5月11日,AWSome Day移師羊城 廣州站期待你的到來! 點選