Hello World! Introducing Language Syntax Tips

Ever wondered how to say Hello world in 38 different programming languages? CodeSignal has you covered!

We just launched Syntax Tips, a brand-new feature in all of our coding tasks and challenges that gives you important information about how to format code in every programming language that our platform supports.

It can be hard to remember how to format a function, write a comment, print to the console, or return output in a specific language. This is especially true if you’re just learning the language, or if it’s one that you don’t use very frequently. So this is going to come in very handy!

Hello world

Gif of all supported programming languages on CodeSignal
Hello world in 38 languages!

Think of Syntax Tips as your own personal Rosetta Stone for programming languages. To see tips for a particular language, just choose that language from the dropdown menu at the top right side of the code editor. (This is also how you change the language that you’re writing in to solve a task.)

Hello world in JavaScript

You do not need to do anything different to access Syntax Tips. This section is now at the bottom of every coding task’s description section, no matter which CodeSignal mode you’re using.

Just as a reminder, CodeSignal now supports 38 different programming languages: ClojureCoffeeScript, Common Lisp, C, C++, C#, D, Dart, Elixir, Erlang, Free Pascal, Fortran, F#GoGroovyHaskellJavaJavaScript / ES6JuliaKotlinLuaNimObjective-COCamlGNU OctavePerlPHPPython 2Python 3RRubyRustScalaSmalltalkSwift 3TclTypeScript, and Visual Basic.

If your favorite language isn’t on this list yet, don’t worry. Because we know how important it is for you to be able to practice programming in the language of your choice, we add new language support to CodeSignal all the time. (Seems like just yesterday that we only had 14 languages, and look at us now!)

Tell us…

What you you think of Syntax Tips? Let us know over on the CodeSignal user forum!

Interview Basics: Multidimensional Arrays

Multidimensional Arrays

Did you read last week’s article on static vs dynamic arrays? If not, catch up now! This week we’re continuing the arrays theme and discussing multidimensional arrays. This is another data structure that you absolutely have to know to succeed in technical interviews, which is why several of our array questions in Interview Practice feature them.

Multidimensional Array Basics

What makes a multidimensional array different from a plain old array? And just what is a multidimensional array, anyway? 

Basically, a multidimensional array is also a random-access data structure, but in this case the data is accessed by more than one index.

Some languages like C# have built-in support for multidimensional arrays. But other languages support multiple indices by creating an “array of arrays”. A multidimensional array in which you need N numbers to reference a particular piece of data is an N-dimensional array. In other words, N is the number of indices needed to locate a single element in the array.

How do you access elements in a multidimensional array? In the “array of arrays” model, the elements at arr[i] are arrays themselves. And element arr[i][j] is the jth element in the array arr[i]. These arrays can be dynamic or static.

The good: The item lookup by index for multidimensional arrays is O(1), and it’s easy to iterate over every element stored in a multidimensional array. You can use multiple indices that make sense for the problem you’re solving (consider using rows and columns for a problem about a chess board, for example), which makes it easier for you to read and maintain your code.

The bad: It’s not easy or quick to rearrange the elements in a multidimensional array, and it requires a long time to change its size.

Meet the 2D Array

Technically, it’s possible to have a multidimensional array of any size. But for technical interviews, it’s most important for you to be familiar with 2D arrays. 2D arrays are often used to implement:

  • Matrices, where `matrix[i][j]` represents the element at row `i` and column `j`;
  • Game boards like chess or checkers boards, where `board[row][col]` represents the state of the board at the location `(row, col)`;
  • Maps, in which the map is divided into cells to represent different locations.

Jagged vs Regular Arrays

As we mentioned earlier, different languages have different ways of representing this kind of array. When implementing a 2D array as an “array of arrays” (i.e. arr[i] is itself an array), there is no technical reason why len(array[i]) == len(array[j]). If the subarrays have different lengths, we call this a jagged array.

jagged multidimensional array
A jagged multidimensional array

But when we talk about multidimensional arrays, we often mean regular (or rectangular) arrays, in which each dimension has a fixed length.

regular multidimensional array
A regular multidimensional array

TL;DR? Watch this video instead!

More of a visual learner? We get it. Watch this video to get up to speed on the basics of multidimensional arrays!

Up to speed on this handy data structure? Head on over to the arrays section of Interview Practice to solve some real multidimensional array-based technical interview questions!