由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 矩阵变换题
相关主题
报一个bloomberg offer大数乘法的另类解法
reverse bits problem【From LIA】请参与“一人一签”行动,到LIA网站登记
今天突然想写这个:位运算题目总结问个sql问题
有没有人发现pinterest有个bug啊SQL combine two columns from two different tables no shared columns
大雪天裸体跪问关于young tableau的几道题目~~~dp真优美,matrix chain multiplication 解法
说一下我最近面过的题吧烙印太牛了。。。
问一道字符串相关的题目。请教一道google面试算法题
请教个面试题JOB:Sr. Scientist Bioanalytical Mass Spectrometry
相关话题的讨论汇总
话题: row话题: column话题: solution话题: toggle话题: final
进入JobHunting版参与讨论
1 (共1页)
j****7
发帖数: 30
1
Given two square matrices(initial and final) consisting of elements either
1 or 0. Using minimum number of toggles change the initial to final matrix.
You can toggle either a single row or column at a time. If ith row is
toggled all 1's become 0 and vice versa in that row.
What will be the correct algorithm for this?
For example
|0 0 1|
|1 1 1|
|1 0 1|
to
|1 1 1|
|1 1 0|
|1 0 0| would require
1st row and last column toggle.
Thanks
g*********s
发帖数: 1782
2
a* search? eval::=final - trial and always pick up the move closest to
all-0 matrix.
however it also needs some mathematical thinking about the solvability.

either
matrix.

【在 j****7 的大作中提到】
: Given two square matrices(initial and final) consisting of elements either
: 1 or 0. Using minimum number of toggles change the initial to final matrix.
: You can toggle either a single row or column at a time. If ith row is
: toggled all 1's become 0 and vice versa in that row.
: What will be the correct algorithm for this?
: For example
: |0 0 1|
: |1 1 1|
: |1 0 1|
: to

z***e
发帖数: 5393
3
my understanding is it's the same as the "word ladder" problem: giving A and
B and some mutation rules, find out the min mutations from A=>B.
so a straightforward solution is to use BFS to find the shortest path from A
=>B.
Unfortunately, the bfs is a "general" solution, but not the best. wonder if
there is better solution for this particular question.

.

【在 j****7 的大作中提到】
: Given two square matrices(initial and final) consisting of elements either
: 1 or 0. Using minimum number of toggles change the initial to final matrix.
: You can toggle either a single row or column at a time. If ith row is
: toggled all 1's become 0 and vice versa in that row.
: What will be the correct algorithm for this?
: For example
: |0 0 1|
: |1 1 1|
: |1 0 1|
: to

b***e
发帖数: 1419
4
Yes, there is a simple solution here, which is no more than to solve a
set of linear equations.
Taking the example in OP as an example:
1. computer the xor, we get:
1 1 0
0 0 1
0 1 1
2. linearize it, top to bottom, left to right, let R be:
1 1 0 0 0 1 0 1 1
3. List all the transformations you can do, let T be:
1 1 1 0 0 0 0 0 0
0 0 0 1 1 1 0 0 0
0 0 0 0 0 0 1 1 1
1 0 0 1 0 0 1 0 0
0 1 0 0 1 0 0 1 0
0 0 1 0 0 1 0 0 1
4. Let T' be the transit of T, and R' be the transit of R (so R's is a
column). Now the problem becomes as simple as to find solution for:
T' * X = R'
where multiplication and addition are all modulo 2.
The key is to note that, you will only need to flip a row/col at most
once,
and the order in which you flip it doesn't matter.
1 (共1页)
进入JobHunting版参与讨论
相关主题
JOB:Sr. Scientist Bioanalytical Mass Spectrometry大雪天裸体跪问关于young tableau的几道题目~~~
一道题说一下我最近面过的题吧
hackerrank weekly contest problem 2, How many Matrices问一道字符串相关的题目。
Facebook onsite 今天1/26面筋【希望不大求bless】请教个面试题
报一个bloomberg offer大数乘法的另类解法
reverse bits problem【From LIA】请参与“一人一签”行动,到LIA网站登记
今天突然想写这个:位运算题目总结问个sql问题
有没有人发现pinterest有个bug啊SQL combine two columns from two different tables no shared columns
相关话题的讨论汇总
话题: row话题: column话题: solution话题: toggle话题: final