LeetSolve
Published in

LeetSolve

C++ Solution to Coding Challenge 1260. Shift 2D Grid

Transforming a 2D vector to a 1D one

C++ Solution to Leetcode 1260. Shift 2D Grid

Problem statement

Given a 2D grid of size m x n and an integer k. You need to shift the grid k times.

In one shift operation:

  • Element at grid[i][j] moves to grid[i][j + 1].
  • Element at grid[i][n - 1]

--

--

LeetSolve shares how to solve a coding question in C++. The questions are selected from leetcode.com. You can learn from LeetSolve’s posts essential algorithms, basic data structures, elementary C++ programming language and common coding techniques.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store