Loading...

Wellesley College Computer Science Club

About

The Wellesley Computer Science Club is dedicated to fostering community within the Computer Science community through events focused on technology, professional development, and academic enrichment.. We strive to provide opportunities for students to connect, collaborate, and deepen their engagement with computer science both inside and outside the classroom.

Calendar

only available to Wellesley students

Resources

CS Course Pre-requisite Diagram Tech Recruitment Guide CS Club Tech Referrals List

Meet the Eboard!

Question of the Week

THIS WEEK'S PROBLEM
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this:
P     A     H     N
A P  L S  I   I  G
Y     I       R
And then read line by line: "PAHNAPLSIIGYIR"
Write the code that will take a string and make this conversion given a number of rows:
string convert(string s, int numRows)


Example 1:
Input: s = "PAYPALISHIRING", numRows = 4
Output: "PINALSIGYAHRPI"
Explanation:
P         I         N
A     L S       I G
Y A     H R
P        I

Constraints:
1 <= s.length <= 1000
s consists of English letters (lower-case and upper-case), ',' and '.'.
1 <= numRows <= 1000

HINT

Could you draw it out in an 2D array?
For better space complexity, what are the gaps in between the elements in each row? Can you use this to traverse the string without building a 2D array?
What are the space and time complexity for these solutions?


                        

Contact

email us for inquiries

Follow Us on Instagram!