Encrypt Text by Columnar Transposition
Updated
Problem statement
For this exercise, use the following columnar transposition rule. Write the characters of text from left to right into rows with columns positions each. The last row may be incomplete. Read the occupied cells column by column, from the leftmost column to the rightmost, and within each column from top to bottom. Return the resulting ciphertext.
For this exercise, assume no padding is added. Preserve every input character, including spaces, punctuation, digits and letter case. Skip unoccupied cells and return an empty string for empty text.
Function
encryptTransposition(text: String, columns: int) → StringExamples
Example 1
text = "WEAREDISCOVERED"columns = 4return = "WECREDOEAIVDRSE"The columns contain WECR, EDOE, AIVD and RSE, read in that order.
Example 2
text = "abcde"columns = 3return = "adbec"Rows are abc and de. Read ad, be and c without adding padding.
Constraints
- For this exercise, assume
0 <= text.length <= 500and1 <= columns <= 500. - For this exercise, assume every input character is printable ASCII, from character code 32 through 126.
More Palantir interview questions
- Balanced Session ManagerPHONE SCREEN · Seen Nov 2026
- Query Words Within K PositionsPHONE SCREEN · Seen Nov 2026
- Employees With Shared InterestsPHONE SCREEN · Seen Jul 2025
- Merge a 2048 RowPHONE SCREEN · Seen Jan 2025
- Encrypt Letters by First-Occurrence SubstitutionPHONE SCREEN · Seen Aug 2022
- Basic Item DiscountsOA · Seen Nov 2026
- Optimize Discount Selection Under a Point BudgetOA · Seen Nov 2026
- Stacked Item and Category DiscountsOA · Seen Nov 2026
- Map and Accumulate Learning QueriesONSITE INTERVIEW · Seen Oct 2026
- Relational Learning QueriesONSITE INTERVIEW · Seen Apr 2025
Similar questions at other companies
- Ordered IP FirewallDatabricks · PHONE SCREENDatabricks interview questions
- Rank Word-Translation Hints from Sentence TranslationsDuolingo · PHONE SCREEN · ONSITE INTERVIEWDuolingo interview questions
- Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
- Largest Number Below N from Reusable DigitsByteDance · PHONE SCREENByteDance interview questions
- Merge Weekday and Time IntervalsNextdoor · PHONE SCREENNextdoor interview questions
- Group AnagramsWorkday · PHONE SCREEN
- Apply Operations to Make a String EmptyFlexport · PHONE SCREENFlexport interview questions
- Elevator Scheduling SimulationOpenAI · PHONE SCREENOpenAI interview questions
- Word BreakAmazon · PHONE SCREEN · ONSITE INTERVIEW
Palantir interview experiences
- Palantir SWE New Grad - Gotham
- Palantir FDSE Experienced-Hire Interviews: 5 Experiences
- Palantir FDSE New Grad OA Questions: 6 Experiences (Part 2 of 2)
- Palantir FDSE New Grad Interviews: 5 Experiences (Part 1 of 2)
- Palantir FDSE Intern OA and Interviews: 3 Experiences
- Palantir FDSE Karat and Learning: 7 Experiences (Part 2 of 2)