id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

simona1@sfusd.edu two_d_arrays > isSymmetric
prev  |  next  |  chance

Write a boolean method named isSymmetric whose parameter is a String that represents a rectangular two dimensional array of ints, representing a matrix. Convert it to a two dimensional array with method toArray(). isSymmetric will return false if any element doesn't match its opposite (reflected across the row=column line, otherwise true. It will also return false if the array isn't square. For example, {{1,2,3},{2,1,4},{3,4,1}} is symmetric. It may help to write these as square matrices to see the symmetry. The line of symmetry is all ones in this example. You must cut and paste method toArray() from the hint.


isSymmetric("{{1,0},{0,1}}") → true
isSymmetric("{{}}") → false
isSymmetric("{{3}}") → true

...Save, Compile, Run (ctrl-enter)

public boolean isSymmetric(String s) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 350 Post-solution available

Copyright Nick Parlante 2017 - privacy