Do not go gentle into that good night. Rage, rage against the dying of the light.
- Seattle, WA
-
03:09
(UTC -07:00) - http://cruxrebels.wordpress.com
- in/abhiagx
Pinned Loading
-
InterviewBit
InterviewBit PublicA collection of Abhishek Agrawal's C++ solutions providing scalable, production-quality code to 200+ LeetCode-style problems on https://www.interviewbit.com, designed to enhance algorithmic skills …
-
You are in an infinite 2D grid where...
You are in an infinite 2D grid where you can move in any of the 8 directions : (x,y) to (x+1, y), (x - 1, y), (x, y+1), (x, y-1), (x-1, y-1), (x+1,y+1), (x-1,y+1), (x+1,y-1) You are given a sequence of points and the order in which you need to cover the points. Give the minimum number of steps in which you can achieve it. You start from the first point. Example : Input : [(0, 0), (1, 1), (1, 2)] Output : 2 It takes 1 step to move from (0, 0) to (1, 1). It takes one more step to move from (1, 1) to (1, 2). This question is intentionally left slightly vague. Clarify the question by trying out a few cases in the “See Expected Output” section. Tags: InterviewBit Arrays Problem https://www.interviewbit.com/problems/min-steps-in-infinite-grid/ 1/*
2You are in an infinite 2D grid where you can move in any of the 8 directions :
3(x,y) to (x+1, y), (x - 1, y), (x, y+1), (x, y-1), (x-1, y-1), (x+1,y+1), (x-1,y+1), (x+1,y-1)
4You are given a sequence of points and the order in which you need to cover the points.
5Give the minimum number of steps in which you can achieve it. You start from the first point.
-
Given a positive integer which fits ...
Given a positive integer which fits in a 32 bit signed integer, find if it can be expressed as A^P where P > 1 and A > 0. A and P both should be integers. Example Input : 4 Output : True as 2^2 = 4. Tags: InterviewBit Math Problem https://www.interviewbit.com/problems/power-of-two-integers/ 1bool Solution::isPower(int A) {
2if (A<2)
3return true;
45for (auto i = 2; i<=sqrt(A); ++i)
-
Given a matrix of m * n elements (m ...
Given a matrix of m * n elements (m rows, n columns), return all elements of the matrix in spiral order. Example: Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] You should return [1, 2, 3, 6, 9, 8, 7, 4, 5]. Tags: InterviewBit - Arrays topic (https://www.interviewbit.com/problems/spiral-order-matrix-i/). 1vector<int> Solution::spiralOrder(const vector<vector<int> > &A) {
2vector<int> result;
3// DO STUFF HERE AND POPULATE result
4auto rows = A.size();
5if (rows == 0)
Something went wrong, please refresh the page to try again.
If the problem persists, check the GitHub status page or contact support.
If the problem persists, check the GitHub status page or contact support.