is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
Not sure I understand the 4 cases, but here's my interpretation and solution.
- a triangle is a square block which contains a triangle in it, it can be of any size, (2x2, 3x3, 4x4...).
- a triangle is a block which has ones on one corner and zeros on the other corner... for example
is a triangle
- I excluded the triangles that have other stuff in the square like
Not a triangle. But not sure if it should be... from the question. Would need clarifications on this. If this is an acceptable triangle, we'd have the template be
[1,1,1
1,1,0
1,0,-1] where -1 is a don't care, shown later in the template making function. We really just need a solid triangle of 1s, and a line of 0 which is a boundary of the triangle, and the rest of the square, we don't really care.
This is the solution presented here as I find it's a bit more flexible and intuitive to someone looking for triangles.
My code uses somewhat of an image processing, template matching approach. I make 4 templates of triangles and convolve them on the matrix, counting everytime we find a match. I then increase the size of the triangle and convolve again, until the triangle is the size of the matrix, which I assumed to be square as stated in the question, but is not the case in the example.
gives us 18 triangles
- djtrance January 31, 2016