1. Alert Service

C#

C#

The C# programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.

Refactoring

Refactoring

The process of restructuring existing computer code without changing its external behavior. It is essential for keeping code readable and maintainable.

Public

Public

Public questions (free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.

New

New

This is a part of latest question addition to our question library.

Refactor the AlertService and AlertDAO classes:

Create a new interface, named IAlertDAO, that contains the same methods as AlertDAO.

AlertDAO should implement the IAlertDAO interface.

AlertService should have a constructor that accepts IAlertDAO.

The RaiseAlert and GetAlertTime methods should use the object passed through the constructor.

The RaiseAlert and GetAlertTime methods use IAlertDAO passed through constructor: Wrong answer

2. Merge Names

C#

C#

The C# programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.

Arrays

Arrays

An array is a container of a fixed number of objects of a similar type. It is a fundamental component of most programming languages.

Public

Public

Public questions (free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.

New

New

This is a part of latest question addition to our question library.

Implement the UniqueNames method. When passed two arrays of names, it will return an array containing the names that appear in either or both arrays. The returned array should have no duplicates.

Arrays have some names in common: System.NotImplementedException at MergeNames.UniqueNames(String[] names1, String[] names2) in MergeNames.cs:line 7

3. Palindrome

C#

C#

The C# programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.

Strings

Strings

The string data structure is used to represent text. It is one of the most commonly used data structures. Therefore, every programmer should be skilled at string manipulation.

Public

Public

Public questions (free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.

A palindrome is a word that reads the same backward or forward.

Write a function that checks if a given word is a palindrome. Character case should be ignored.

For example, IsPalindrome("Deleveled") should return true as character case should be ignored, resulting in "deleveled", which is a palindrome since it reads the same backward and forward.

Various words: System.NotImplementedException at Palindrome.IsPalindrome(String word) in Palindrome.cs:line 7

4. Binary Search Tree

C#

C#

The C# programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.

Algorithmic thinking

Algorithmic thinking

When designing and/or analyzing an algorithm or data structure, it is important to consider the performance and structure of an implementation. Algorithmic thinking is one of the key traits of a good programmer, especially one working on complex or performance-critical code.

Data structures

Data structures

Choosing the right data structure to solve a problem can have huge implications on the performance of an application. Knowing when to use a specific data structure is one of the most important skills for a programmer.

Public

Public

Public questions (free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.

Binary search tree (BST) is a binary tree where the value of each node is larger or equal to the values in all the nodes in that node's left subtree and is smaller than the values in all the nodes in that node's right subtree.

Write a function that, efficiently with respect to time used, checks if a given binary search tree contains a given value.

For example, for the following tree:

n1 (Value: 1, Left: null, Right: null)

n2 (Value: 2, Left: n1, Right: n3)

n3 (Value: 3, Left: null, Right: null)

Call to Contains(n2, 3) should return true since a tree with root at n2 contains number 3.

Performance test on a large tree: System.NotImplementedException at BinarySearchTree.Contains(Node root, Int32 value) in BinarySearchTree.cs:line 23

5. Playlist

C#

C#

The C# programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.

Algorithmic thinking

Algorithmic thinking

When designing and/or analyzing an algorithm or data structure, it is important to consider the performance and structure of an implementation. Algorithmic thinking is one of the key traits of a good programmer, especially one working on complex or performance-critical code.

Searching

Searching

Every programmer should be familiar with data-searching methods, as they are very common in data-analysis processes.

Public

Public

Public questions (free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.

New

New

This is a part of latest question addition to our question library.

A playlist is considered a repeating playlist if any of the songs contain a reference to a previous song in the playlist. Otherwise, the playlist will end with the last song which points to null.

Implement a function IsRepeatingPlaylist that, efficiently with respect to time used, returns true if a playlist is repeating or false if it is not.

For example, the following code prints "True" as both songs point to each other.

Song first = new Song("Hello");
Song second = new Song("Eye of the tiger");
first.NextSong = second;
second.NextSong = first;
Console.WriteLine(first.IsRepeatingPlaylist());

Song will repeat: System.InvalidOperationException at Song.IsRepeatingPlaylist() in Playlist.cs:line 15

Song will not repeat: System.InvalidOperationException at Song.IsRepeatingPlaylist() in Playlist.cs:line 15

Performance test on a large playlist: System.InvalidOperationException at Song.IsRepeatingPlaylist() in Playlist.cs:line 15

6. User Input

C#

C#

The C# programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.

OOP

OOP

Object-oriented programming is a paradigm based on encapsulating logic and data into objects, which may then contain fields and procedures. Many of the most widely used programming languages are based on OOP, making it a very important concept in modern programming.

Public

Public

Public questions (free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.

User interface contains two types of user input controls: TextInput, which accepts all characters and NumericInput, which accepts only digits.

Implement the class TextInput that contains:

Public method void Add(char c) - adds the given character to the current value

Public method string GetValue() - returns the current value

Implement the class NumericInput that:

Inherits TextInput

Overrides the Add method so that each non-numeric character is ignored

Adding various characters to NumericInput: System.InvalidCastException

7. Account Test

C#

C#

The C# programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.

Test case design

Test case design

Being able to create a set of test cases that ensure adequate test coverage is a key skill for creating a successful test. It is desirable for the test suite also to be optimal, i.e. to minimize test execution effort and time without affecting the test coverage.

Public

Public

Public questions (free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.

New

New

This is a part of latest question addition to our question library.

Using only NUnit's Assert.AreEqual method, write tests for the Accountclass that cover the following cases:

The Deposit and Withdraw methods will not accept negative numbers.

Account cannot overstep its overdraft limit.

The Deposit and Withdraw methods will deposit or withdraw the correct amount, respectively.

8. Two Sum

C#

C#

The C# programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.

Algorithmic thinking

Algorithmic thinking

When designing and/or analyzing an algorithm or data structure, it is important to consider the performance and structure of an implementation. Algorithmic thinking is one of the key traits of a good programmer, especially one working on complex or performance-critical code.

Searching

Searching

Every programmer should be familiar with data-searching methods, as they are very common in data-analysis processes.

Public

Public

Public questions (free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.

Write a function that, when passed a list and a target sum, returns, efficiently with respect to time used, two distinctzero-based indices of any two of the numbers, whose sum is equal to the target sum. If there are no two numbers, the function should return null.

For example, FindTwoSum(new List<int>() { 3, 1, 5, 7, 5, 9 }, 10) should return a Tuple<int, int> containing any of the following pairs of indices:

Distinct numbers with and without solutions: System.NotImplementedException at TwoSum.FindTwoSum(IList`1 list, Int32 sum) in TwoSum.cs:line 8

Duplicate numbers with and without solutions: System.NotImplementedException at TwoSum.FindTwoSum(IList`1 list, Int32 sum) in TwoSum.cs:line 8

Performance test with a large list of numbers: System.NotImplementedException at TwoSum.FindTwoSum(IList`1 list, Int32 sum) in TwoSum.cs:line 8

9. Account

C#

C#

The C# programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.

Enum

Enum

An Enum or Enumerated type, is a data type that consists of a set of named values. As most programming languages implement the enum type as one of their primitives it's an important concept for all developers.

Public

Public

Public questions (free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.

New

New

This is a part of latest question addition to our question library.

Each account on a website has a set of access flags that represent a users access.

Update and extend the enum so that it contains three new access flags:

A Writer access flag that is made up of the Submit and Modify flags.

An Editor access flag that is made up of the Delete, Publish and Comment flags.

An Owner access that is made up of the Writer and Editor flags.

For example, the code below should print "False" as the Writer flag does not contain the Delete flag.

10. Decorator Stream

C#

C#

The C# programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.

Stream

Stream

A stream is a sequence of data elements made available over time. It is particularly useful for tasks that may benefit from being asynchronous, including tasks such as I/O processing or reading from a file, and as such is important for developers to understand.

Public

Public

Public questions (free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.

New

New

This is a part of latest question addition to our question library.

Implement methods and properties in the DecoratorStream class:

Write method should write the prefix into the underlying stream member only on the first Write invocation. It should always write the bytes it receives to the underlying stream.

The prefix should be written in UTF-8 encoding.

For example, if the DecoratorStream is instantiated with "First line: " as the prefix parameter and Write method is called with UTF-8 byte representation of "Hello, world!", it should write "First line: Hello, world!" into the underlying stream.

11. Folders

C#

C#

The C# programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.

Serialization

Serialization

Familiarity with data serialization to and from formats such as XML and JSON is important as it is commonly used for interprocess communication

Public

Public

Public questions (free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.

Implement a function FolderNames, which accepts a string containing an XML file that specifies folder structure and returns all folder names that start with startingLetter. The XML format is given in the example below.

12. Sorted Search

C#

C#

The C# programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.

Algorithmic thinking

Algorithmic thinking

When designing and/or analyzing an algorithm or data structure, it is important to consider the performance and structure of an implementation. Algorithmic thinking is one of the key traits of a good programmer, especially one working on complex or performance-critical code.

Searching

Searching

Every programmer should be familiar with data-searching methods, as they are very common in data-analysis processes.

Public

Public

Public questions (free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.

Implement function CountNumbers that accepts a sorted array of unique integers and, efficiently with respect to time used, counts the number of array elements that are less than the parameter lessThan.

For example, SortedSearch.CountNumbers(new int[] { 1, 3, 5, 7 }, 4) should return 2 because there are two array elements less than 4.

13. Train Composition

C#

C#

The C# programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.

Algorithmic thinking

Algorithmic thinking

When designing and/or analyzing an algorithm or data structure, it is important to consider the performance and structure of an implementation. Algorithmic thinking is one of the key traits of a good programmer, especially one working on complex or performance-critical code.

Data structures

Data structures

Choosing the right data structure to solve a problem can have huge implications on the performance of an application. Knowing when to use a specific data structure is one of the most important skills for a programmer.

Public

Public

Public questions (free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.

A TrainComposition is built by attaching and detaching wagons from the left and the right sides, efficiently with respect to time used.

For example, if we start by attaching wagon 7 from the left followed by attaching wagon 13, again from the left, we get a composition of two wagons (13 and 7 from left to right). Now the first wagon that can be detached from the right is 7 and the first that can be detached from the left is 13.

Several wagons: System.NotImplementedException at TrainComposition.AttachWagonFromRight(Int32 wagonId) in TrainComposition.cs:line 12

Performance test with a large number of wagons: System.NotImplementedException at TrainComposition.AttachWagonFromRight(Int32 wagonId) in TrainComposition.cs:line 12

14. Path

C#

C#

The C# programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.

Data structures

Data structures

Choosing the right data structure to solve a problem can have huge implications on the performance of an application. Knowing when to use a specific data structure is one of the most important skills for a programmer.

Strings

Strings

The string data structure is used to represent text. It is one of the most commonly used data structures. Therefore, every programmer should be skilled at string manipulation.

Public

Public

Public questions (free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.