Giter Club home page Giter Club logo

matrix_check_sum's Introduction

Matrix: Check sum

Checks if the sum of values in a given row matches the sum of values in the corresponding column.

Exercise

  • A method takes an input parameter that is a matrix of integers where the number of rows are equal to the number of columns. e.g. 3 rows and 3 columns, 7 rows and 7 columns or n rows and n columns. The method returns true if the sum of all elements in each row matches the sum of all elements in the corresponding column. Otherwise, it returns false.
  • e.g. In an input matrix with 2 rows and 2 columns, if the sum of all elements in the row at index 0 matches the sum of all elements in the column at index 0, and the sum of all elements in the row at index 1 matches the sum of all elements in the column at index 1, then the method will return true.
  • Consider the example input:
1 2 3 4
9 5 3 1
0 3 5 6
0 8 3 6
  • In the above example case, the method should return true. (Sum of 0th row and 0th column is 10, sum of 1st row as well as the 1st column is 18 and so on.)
  • Share and explain the time and space complexities for your solution.
  • If you think of multiple approaches to solve the problem, implement the solution which minimizes space complexity. Explain the other approaches, and your decision in comments above the code.

matrix_check_sum's People

Contributors

hamled avatar shrutivanw avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.