Sunday, October 24, 2010

Microsoft Interviews, again

I had series of interviews here at Microsoft, for SDEII positions. I don’t know results yet, but I think I can share some questions I was asked:

1. Design and code algorithm that determines whether liked list is cycled.
2. Given an array of strings, print all groups of anagrams in array (like Group 1: “abc, cba”, Group 2: “demo, mode”).
3. Reverse linked list. For instance, given linked list "A –> B –> C –> D”, you’ll need to get “D –> C –> B –> A”. Design, analyze algorithm and code.
4. Print all possible paths in matrix, from lower left corner to upper right. Design, analyze and code algorithm.
5. Design elevators management system (1 building, 6 elevators).
6. You have 100 storey building and 2 marbles. You need to find a floor when marbles being thrown from the floor will break in a least number of measurements.
7. You have a matrix m x n. It contains numbers sorted in ascending order by rows and by columns. You need to find a most efficient algorithm to find a number in that matrix.

Enjoy.

Wednesday, October 6, 2010

How do I – Android: Check current SDK version in application

Its never been easier to check current SDK version your device is running on. Use

Build.VERSION.SDK_INT

it contains value from Build.VERSION_CODES enumeration. For instance, following code determines whether current version is Froyo or higher:

/** 
* Checks if SDK device is running on is Froyo or higher.
 
*
 
*
@return True, if SDK device is running on is Froyo or higher; otherwise false.
 */
public boolean isSdkFroyoOrHigher() {
      return Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO;
}

How do I – Android: Check if SD card is present

Sometimes its necessary to know whether device has SD card present (mounted), before start doing any operation(s) with it. So, here is some simple way to determine is SD card mounted:

/**
 * Checks if SD card is mounted.
 *
 * @return True, if SD card is mounted.
 */
public boolean isSDCardMounted() {
      return android.os.Environment.getExternalStorageState().equals(
            
android.os.Environment.MEDIA_MOUNTED);
}

That’s it, if its mounted, you’ll get true, otherwise false.

How do I – Android: Unmount SD card

Simple question, but sometimes people don’t know how to do this. So, in order to unmount SD card on Android do the following:

  • Open “Settings”
  • Go to “SD card & phone storage”
  • Press “Unmount SD card”

This is all you need to do :)

image