楼主: Fanyare
跳转到指定楼层
上一主题 下一主题
收起左侧

[CareerCup] [第二轮] 2/18-2/24 CareerCup 1.6

全局:
Rotate right. Do the rotate from edges to the central part.

https://gist.github.com/lynntian/5001216
回复

使用道具 举报

全局:
Arthur2012 发表于 2013-2-19 15:19
At first turn 180 degree, and then turn through back-diagonal.
https://github.com/Tedatworking/Care ...

I had difficulty understanding c++ codes. But based on your loops, I think we solve the problem in the same way. ;)
回复

使用道具 举报

🔗
moophis 2013-2-21 18:39:28 | 只看该作者
全局:
https://github.com/moophis/careercup/blob/master/1.6.cpp
My thought is almost identical with grassgigi
回复

使用道具 举报

🔗
Kimurate 2013-2-21 19:54:29 | 只看该作者
全局:
回复

使用道具 举报

🔗
youling_tong 2013-2-22 09:51:51 | 只看该作者
回复

使用道具 举报

🔗
 楼主| Fanyare 2013-2-23 00:45:02 | 只看该作者
全局:
回复

使用道具 举报

🔗
lazyGoose 2013-2-23 05:32:29 | 只看该作者
全局:
本帖最后由 lazyGoose 于 2013-2-23 05:36 编辑

Create a temp array and add to the temp one by one.

     if (clockwise)   temp[j][n - i - 1] = a[i][j];
     if(!clockwise)   temp[n - j - 1][i] = a[i][j];


https://gist.github.com/lazyGoose/5016708
回复

使用道具 举报

🔗
lazyGoose 2013-2-23 05:34:46 | 只看该作者
全局:
Fanyare 发表于 2013-2-23 00:45
https://github.com/quantumrose/CareerCup/blob/master/1.6.Rotate.java

O(n^2) time, in place

hi, how to calculate the Time Complexity, could you provide me with some reading?

点评

http://en.wikipedia.org/wiki/Time_complexity http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o hope it helps:)  发表于 2013-2-24 10:14
回复

使用道具 举报

🔗
yukainuo23 2013-2-23 07:52:48 | 只看该作者
全局:
本帖最后由 yukainuo23 于 2013-2-23 08:04 编辑

https://gist.github.com/KainuoYU/5017549

filp and transpose!
回复

使用道具 举报

🔗
ThunderXu 2013-2-23 13:41:56 | 只看该作者
全局:
https://gist.github.com/ThunderXu/5018599
从最外层到最里层逐层反转
顺时针的话:
int temp = mat[j][size-1-i];
mat[j][size-1-i]=mat[i][j];
mat[i][j]=mat[size-1-j][i];
mat[size-1-j][i]=mat[size-1-i][size-1-j];
mat[size-1-i][size-1-j]=temp;
逆时针相反

在纸上画了半天才画出来,还是分成两步的方法简单明了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表