↳
Actually the answer is zero. Plans fly, people don't.
↳
Roughly as many who flew into Chicago.
↳
oops - typo - Planes fly, people don't
↳
This was the first question I was asked and is considered a warm up.
↳
anon.. would this work for a number like 17 (10001)?
↳
bool checkPalindrome(unsigned int n) { int m = n, k =0; bool ret = false; while(m!=0) { int i = 1; i = i & m; k = k > 1; } if((k^n)==0) { cout<<"Palindrome"< Menos
↳
Otherwise called the sliding window problem
↳
You can access the list only 3 numbers at a time: It tells we can read three numbers one after other in N/3 Iterations. So Time complexity will be O(N/3) Menos
↳
This is sliding window problem and priority queue DS can be used to solve this.
↳
there is rol and ror operations which can be useful to shift places and also the left most digit can move to the end during the operation. Menos
↳
http://www.intel.com/software/products/documentation/vlin/mergedprojects/analyzer_ec/mergedprojects/reference_olh/mergedProjects/instructions/instruct32_hh/vc270.htm this might be helpful Menos
↳
unsigned int a=123; // Given number unsigned int b=0; /// temp variable int i; for(i=0; i>1; } Menos
↳
Sorting makes the time complexity as O(nlogn). An O(n) solution was asked for
↳
package array; import java.util.Hashtable; /* * You are given an array of numbers. * You need to print the length of the maximum continuous sequence that you encounter. * For example if input is [3,8,10,1,9,6,5,7,2 ], * the continuous sequences are{1,2,3} and {5,6,7,8,9,10} * the latter is the longest one so the answer becomes 6. * O(n) solution was asked for, * assuming you have a hash map which supports O(1) insertion and fetching operations * src: http://www.glassdoor.com/Interview/Microsoft-India-Interview-Questions-EI_IE1651.0,9_IL.10,15_IN115_IP6.htm */ public class FindLengthOfLongestRandomlyDistContinousSequenceOfNumber { public static void main(String[] str){ int a[] = {3,6,8,1,5,7,0,9,2,4,10,14,13,12,11}; System.out.println(findLength(a)); int b[] = {5,2,3,1,6,7,10,8}; System.out.println(findLength(b)); } private static int findLength(int[] a) { int result = 0; Hashtable h = new Hashtable(); for(int i=0; i result){ result = curr.maxValue; } if(next != null){ next = h.get( curr.max); next.maxValue = curr.maxValue; h.put(a[i]+1, next); next.min = curr.min; } if(prev != null){ prev = h.get(curr.min); prev.maxValue = curr.maxValue; h.put(a[i]-1, prev); prev.max = curr.max; } h.put(a[i], curr); } } return result; } } class Node{ int maxValue; int max; int min; public Node(int v, int m, int n){ maxValue = v; max = m; min = n; } } Menos
↳
static int findlongconsecutivesubseq(int[] arr) { HashSet s= new HashSet(); int ans=0; //put all entries in hashset for(int i=0;i ans) ans=j-arr[i]; } } return ans; } Menos
↳
For K smallest number in series you can use a max heap of size k. When you find a new number and it is smaller than root of heap, swap it with root and heapify. Menos
↳
@Ajit: What're the initial values of the max heap? What happens to the first value that comes in? Menos
↳
Use selection sort for 'max' ( or for 'min') If K > series.length/2 then reverse the criteria- like in stead of looking for 15th highest out of 20 element array - look for (20 -15 =) 5th lowest and so on.... Menos
↳
OLA Test Cases - Test the installation and Unistallation of the App - Test the login and log out of the account - Test the emergency contact receives the SMS when a ride is started - Test the signup for new user - Test the ride using ola money - Test the ola money transfer after KYC has been done - Test the ola money transfer without doing KYC - Test the current location picked when opened the app - Test the favorite marking of the locations - Test the picking of desired location - Test the vehicle availability in mins for all the types - Test the vehicle availability says no when there's no active driver for that type - Test the vehicle option from source to destination - Test the source and destination are interstate - Test the source and destination are intercountry through land - Test the source and destination has no roadways - Test the source and destination between two planets - Test the driver allocated for the ride can be called from the deep link of the app - Test the money displayed before the ride and after ride are same when taken the given route - Test the money displayed before the ride and after ride changes when taken the short/long route - Test the choice of source and destination by giving lat and longs for that location - Test the driver arrived indication is notified once he marked reached. - Test the booking during rush hours when the demand is more - Test the 'sorry cab didn't found' message when the search completes without booking a cab - Test the OTP generation - Test the SMS delivered for the booked cab or auto - Test the OTP starts the ride. Only correct number - Test by giving a random OTP number to start the ride - Test the OTP number by giving vehicle number - Test the auto deduction of ola money when the ride completes - Test the cancellation of OLA cab/auto - Test the cancellation charge applied after crossing the cancellation limit for that month - Test the promo code works for each ride - Test the OLA pass is applied if the pass hasn't been expired - Test the fare changes for each variant like Prime, Mini, Micro - Test Ola outstation verification - Test the late night charges are higher than the usual - Test the cab driver cancellation of the current booking notified in the SMS and Ola app - Test the booking when the network has a weak signal strength Menos
↳
Google Hangout - Unable to do video chat - Check whether the camera is turned on - Check whether the connected device have camera option - Check whether the internet connection is switched off - Check the video chat after refreshing or restarting the app - Check whether the Gmail account had been logged out - Check whether the camera option is disabled in the device - Check whether the camera is not working in the device - Check by opening the hangout in the mobile or other device - Check by opening the hangout in different browser window - Check by opening the hangout in different browser - Check whether the javascript is disabled - Check after clearing the cache of the browser - Check after clearing the cookie of the browser Menos
↳
def maxRepeating(str): str = str.replace(" ", "") print(str) n = len(str) count = 0 res = str[0] cur_count = 1 # Traverse string except # last character for i in range(0, n-1): # If current character # matches with next if ( str[i] == str[i + 1]): cur_count += 1 # If doesn't match, update result # (if required) and reset count else: if cur_count > count: count = cur_count res = str[i] cur_count = 1 return res str = "Amazon is a great company as it haas AtoooZzz" print(maxRepeating(str)) Menos
↳
Above answer is not correct. Its a list so you can only start from the begininning. If its a doubly linked list, yes, you can start at the end (and should), but you cannot start "mid-list". Menos
↳
I can think of two ways: 1) traverse from both heads, get two length: long, short traverse again starting from Array1[long-short] and Array2[0], looking for the same pointer O(4n) time, O(1) space 2) use a hash table holds all seen pointers. traverse from both heads O(2n) time, O(n) space Menos
↳
Step 1: if the linked lists are not empty, find the length of each linked list. Since they have a common end point, we will get length of common area of the linked lists too. Step 2: find the difference between the length of both list. Start traverse the biggest list till the difference in length between them, provided one of them is bigger than the other. Step 3: now they are at the same remaining length. Traverse both of the together till both are pointing to the same next node.That node is the common node which is the merging point. If there is no such point, then they are not merged. Menos
↳
Please share the coding questions
↳
Hello, Can you please share how much time did the recruiter take to get to you with an offer? Menos
↳
General QA or a lot of coding related. Thanks