I need help building a coding interview question for a DevOps/SRE position

I’m looking for suggestions on good coding questions for a DevOps/SRE Software Engineer. This is the coding exercise that is done offline or in a platform like HackerRank. The idea is that they would solve the problem, and then extend it during the on-site interview. For other software positions, we’ve done questions like parsing city/state from strings, parsing json where the json isn’t always well-formed, and other problems. The problem is trying to keep the problems from being either overly algorithmic or overly reliant on libraries.

The DevOps/SRE world is a little different, and I think it has different coding requirements. Jumping into existing codebases to figure out what is going on, understanding how software interacts with the OS, etc. So I’m trying to build a coding question that:

  • Can be completed in about an hour by a good candidate
  • Is extensible to accommodate follow-up coding exercises
  • Tests a candidate’s baseline coding proficiency
  • Tests a candidate’s DevOps capabilities (e.g, debugging prowess, scripting, parsing information, or general scrappiness)
  • Has some baseline of problem-solving required (i.e, is not simply mechanical)
  • Does not require a “trick” to solve well
  • The answer is not easy to search on the internet

Xamarin iOS using MVVMCross crashes with not key-value coding compliant

I am building a simple todo app as a demo in Xamarin iOS using MVVMCross. I have built a very similar app in the recent past with no issues. This particular one will not load the first view controller from nib and throws a “this class is not key-value coding compliant for key {control name here}” right away. I have tried rebuilding the nib files, the view controllers and have built the app from scratch multiple times but I cannot get past this issue. I have looked through the documentation and examined many of the demo apps and I cannot find the solution, I am sure it is a simple step I am overlooking somewhere. Any ideas what I might be missing?

The project source is available here.

This is the error

enter image description here

I have double and triple checked the .designer file for errors and to insure the outlets are present.

Here is my first ViewController loaded from a nib

namespace VTSToDoList.iOS.Views { public partial class ToDoListsViewController : MvxViewController<ToDoListViewModel> {     private UIRefreshControl _refreshControl;       public ToDoListsViewController() : base("ToDoListsViewController_View", null)     {      }      public override void ViewDidAppear(bool animated)     {         base.ViewDidAppear(animated);          Refresh();     }      public override void ViewDidLoad()     {         base.ViewDidLoad();          NavigationItem.Title = "Your To Do Lists";          var tableViewSource = new MvxSimpleTableViewSource(ListTableView, nameof(ToDoListsViewController), ToDoListTableViewCell.Key)         {             DeselectAutomatically = true         };         ListTableView.RowHeight = 120;          this.CreateBinding(tableViewSource).To<ToDoListViewModel>(vm => vm.Items).Apply();         this.CreateBinding(this.NewListButton).To<ToDoListViewModel>(vm => vm.AddNewToDoListCommand).Apply();          ListTableView.Source = tableViewSource;         ListTableView.ReloadData();          this.CreateBinding(tableViewSource).For(s => s.SelectionChangedCommand).To<ToDoListViewModel>(vm => vm.ItemSelectedCommand).Apply();          // Create the UIRefreshControl         _refreshControl = new UIRefreshControl();          // Handle the pullDownToRefresh event         _refreshControl.ValueChanged += (object sender, EventArgs e) =>         {             Refresh();         };          // Add the UIRefreshControl to the TableView         ListTableView.AddSubview(_refreshControl);     }      private void Refresh()     {         ViewModel.ReloadDataCommand.Execute(null);         ListTableView.ReloadData();         _refreshControl.EndRefreshing();     } } } 

The View Model

namespace VTSToDoList.Core.ViewModels {  public class ToDoListViewModel : MvxViewModel {     private readonly IMvxNavigationService _navigationService;      public ToDoListViewModel(IMvxNavigationService navigationService)     {         _navigationService = navigationService;         Items = new List<ToDoListModel>();     }      public override async Task Initialize()     {         await base.Initialize();     }      private bool _isEmptyListViewHidden;     public bool IsEmptyListViewHidden     {         get { return _isEmptyListViewHidden; }         set { _isEmptyListViewHidden = value; RaisePropertyChanged(() => IsEmptyListViewHidden); }     }      private bool _isLoading;     public bool IsLoading     {         get { return _isLoading; }         set { _isLoading = value; RaisePropertyChanged(() => IsLoading); }     }      private List<ToDoListModel> _items;     public List<ToDoListModel> Items     {         get { return _items; }         set { _items = value; RaisePropertyChanged(() => Items); }     }      public override void Start()     {         LoadData();     }      private void LoadData()     {         IsLoading = true;         IsEmptyListViewHidden = false;          Task.Run(async () =>         {             var items = await LocalAppStore.Instance.GetItemsAsync();             Items = items;              if (Items.Count > 0)             {                 IsEmptyListViewHidden = false;             }              IsLoading = false;         });     }      private MvvmCross.Commands.MvxCommand _reloadDataCommand;     public System.Windows.Input.ICommand ReloadDataCommand     {         get         {             _reloadDataCommand = _reloadDataCommand ?? new MvvmCross.Commands.MvxCommand(LoadData);             return _reloadDataCommand;         }     }      private MvvmCross.Commands.MvxCommand _addNewToDoListCommand;     public System.Windows.Input.ICommand AddNewToDoListCommand     {         get         {             _addNewToDoListCommand = _addNewToDoListCommand ?? new MvvmCross.Commands.MvxCommand(NavigateToToDoListDetailAsync);             return _addNewToDoListCommand;         }     }      private MvvmCross.Commands.MvxCommand<ToDoListModel> _itemSelectedCommand;     public System.Windows.Input.ICommand ItemSelectedCommand     {         get         {             _itemSelectedCommand = _itemSelectedCommand ?? new MvvmCross.Commands.MvxCommand<ToDoListModel>(DoSelectItem);             return _itemSelectedCommand;         }     }      private void DoSelectItem(ToDoListModel item)     {         _navigationService.Navigate<ToDoListDetailViewModel, ToDoListModel>(item);     }      private void NavigateToToDoListDetailAsync()     {         _navigationService.Navigate<ToDoListDetailViewModel, ToDoListModel>(new ToDoListModel());     }  } } 

Coding Challenge: Return The Lexicographically Smaller String

A coding challenge in which we are to write a function that compares two strings and returns the one that is lexicographically smaller.

Both strings may contain any characters. Consecutive numbers in the string are considered a single number.


input: "a", "b" expected output: "a" since "a" comes before "b" alphabetically

input: "a1", "a2" expected output: "a1" since 1 comes before 2

input: "a10", "a2" expected output: "a2" since 2 comes before 10

Here is the code:

const smallestString = (str1, str2) => {     // we only need to iterate through the shortest string     const len = str1.length < str2.length ? str1.length : str2.length;     for (let i = 0; i < len; i++) {         // check if both letters are strings         if (str1[i].toUpperCase() !== str1[i].toLowerCase() && str2[i].toUpperCase() !== str2[i].toLowerCase()) {             if (str1[i] === str2[i]) { // if both letters are the same, continue                 continue;             } else {                 return str1[i] < str2[i] ? str1 : str2; // otherwise return the string with the 'smaller' char at that index             }         } else if (!isNaN(str1[i] || !isNaN(str2[i]))) { // check if either char is a number             if (!isNaN(str1[i]) && !isNaN(str2[i])) { // if both chars are numbers, return str with numerically smaller number               return parseInt(str1.slice(i)) < parseInt(str2.slice(i)) ? str1 : str2;             }         } else {             return str1[i] < str2[i] ? str1 : str1; // this handles edge cases such as special chars in strings         }     }     return str1; }  console.log(smallestString('a10', 'a2')); // returns 'a2' 

I am seeking any and all feedback about cleaning up the code and possibly improving the algorithm’s current time complexity of O(n).

Agile development: where to include UI coding?

I’ve been doing agile planning for a long time, but always I get to the same question: where should I put the basic UI development tasks? I mean, for example, if we are developing a web app, we need some time to design and develop the basic UI.

Usually, we add extra points to related user stories so we can plan the sprint. Is there a better (or correct) practice?


Correspondence between information theoretic and coding theoretic language?

In information theory capacity or best rate achievement techniques are through showing existence if typical sequences of certain measure while in coding theory performance is measured by number of codewords of minimum weight and minimum weight. What are some of the correspondences between information theoretic and coding theoretic language that may Illuminate relation between achievability and design?

Kraft’s inequality for Huffman coding

Is it true to say that Huffman codes always satisfy Kraft’s inequality with strict equality?

At first, I thought the statement is wrong since for Huffman coding there is no assumptions on the probabilities. However, when I tried evaluation the Kraft inequality for several Huffman codes, I realized that it’s got nothing to do with the probabilities. It’s the algorithm.

I looked for a nice mathematical proof for this, but couldn’t find any. Would appreciate your help.

Coding Challenge Solution – Find Num of Elements in a range in O(1) with preprocessing

This is my solution to the following Coding Challenge – Find Num of Elements in a Range in O(1) with Preprocessing

given array and max element in array. Find no. of elements present between a given range in O(1). You can do one time processing of array. 


#include <iostream> #include <vector> #include <unordered_map> #include <algorithm> using namespace std;  class Solution  {     public:      Solution(vector<int>& v)      {         sort(v.begin(), v.end());           for(unsigned int i=0; i<v.size(); ++i) m[v[i]] = i;      }      unsigned int count(const int a, const int b)     {                if(!(a < b)) throw runtime_error("Wrong Order");          if( (m.find(a) == m.end()) || (m.find(b) == m.end()) ) throw runtime_error("Not Found");          return m[b] - m[a] + 1;      }      private:      unordered_map<int, unsigned int> m;  };   int main() {     // your code goes here     int N;      cin >> N;      vector<int> data;      for(int i=0; i<N; ++i)      {         int temp;          cin >> temp;          data.push_back(temp);      }      Solution sol(data);      const auto left = 1;      const auto right = 3;      const auto res = sol.count(left, right);      cout << "Left = " << left << ", Right = " << right << " --> Res = " << res << endl;      return 0; }  

Notes – Even if typically for Algorithmic Coding Challenges a free function is good enough and using a class is over-engineering, in this specific I went for the class on purpose in order to possibly amortize the pre-processing cost by multiple calls to the count() method

Coding Challenge Solution – Good Range

This my solution to this Good Range Coding Challenge

There is a number space given from 1 to N. And there are M queries followed by that. In each query, we were given a number between 1 to N (both inclusive). We add these number one by one into a set.

Good range: A range in which there is exactly one element present from the set.

For each query, we need to find the good ranges. We need to return the sum of boundry of all good ranges.


First line will take two integer for input N and M. Then following m lines would be numbers between 1 and N (both inclusive).


Following M lines contains sum of boudaries of good ranges.


Range can consist of single element and represented as (x-x) where boundary sum will be x+x.



10 4  2  5  7  9  


11  18  30  46  


step-1) set: 2  good range: (1-10)  sum: 1+10=11   step-2) set: 2 5  good range: (1-4), (3-10)  sum: 1+4+3+10=18   step-3) set: 2 5 7  good range: (1-4), (3-6), (6-10)  sum: 1+4+3+6+6+10=30   step-4) set: 2 5 7 9  good range: (1-4), (3-6), (6-8), (8-10)  sum: 1+4+3+6+6+8+8+10=46 
#include <iostream> #include <set> using namespace std;  class Solution {     public:      Solution(const unsigned int _N, const unsigned int _M) : N(_N), M(_M) {}       void solve()     {         for(unsigned int i=0; i<M; ++i)         {             unsigned int v;              cin >> v;              cout << "New Element = " << v << endl;              q.insert(v);              print_res();              cout << endl;          }     }      void print_res()     {                unsigned int left=1;         auto it=q.begin();          unsigned int last = *it;           for(++it; it!=q.end(); ++it)         {             const unsigned int curr = *it;              const unsigned int right = curr-1;              cout << "[" << left << ", "<< right << "] contains " << last << " and sum = " << (left+right) << endl;              left = last+1;              last = curr;          }         const unsigned right = N;          cout << "[" << left << ", "<< right << "] contains " << last << " and sum = " << (left+right) << endl;      }      private:      unsigned int N;      unsigned int M;      set<unsigned int> q;  };    int main() {     // your code goes here     unsigned int N=0;      unsigned int M=0;      cin >> N >> M;      Solution sol(N,M);      sol.solve();      return 0; }  

Note: I am aware I’m returning more information than required by the problem description but I have chosen to do it to include also debugging information

Daily Coding Challenge solution – day 21

The Challenge Given an array of time intervals (start, end) for classroom lectures (possibly overlapping), find the minimum number of rooms required.

For example, given [(30, 75), (0, 50), (60, 150)], you should return 2.

I believe this code has no errors but if you find any, please do let me know. Otherwise, feel free to use this solution if you get stuck

My Solution

def item_2(element):     return (element[1]) #Returns second element of tuple for sorting   classes = [(15,50),(51,53),(54,58),(60,70),(61,63),(65,69),(71,83)] #classes = [(30, 75), (0, 50), (60, 150), (0, 500), (40, 70)] classes.sort(key=item_2)  print("The following classes will be needed") while classes:     item = classes[0]     index = 0      end_time = item[1]     remaining = classes[1:]     room_bookings = []     room_bookings.append(item)     for next_item in remaining:         if next_item[0] > end_time:             room_bookings.append(next_item)             classes.remove(next_item)             end_time = next_item[1]     print(room_bookings)     classes.remove(item) 

When Huffman coding is inefficient?

I have a question regarding the redundancy of Huffman coding. I know that for a general prefix code we have the following inequality:

H(X) <= R <= H(X) + 1

R being the rate (average codeword lenght) and H is the entropy. Based on this relation, how can we coclude that Huffman coding is very inefficient is entropy of the source is much smaller than 1 bit/symbol?