Categories
 Algorithms (29)
 Concepts (18)
 Data Structures (1)
 Database (17)
 General (22)
 HR (2)
 HTML (1)
 Interview Questions (9)
 Javascript (34)
 PHP (40)
 Security (8)
 Web development (8)

Recent Posts
Meta
Archives
 May 2017 (4)
 April 2017 (25)
 March 2017 (14)
 February 2017 (25)
 January 2017 (4)
 December 2016 (1)
 January 2015 (1)
 October 2014 (13)
 September 2014 (6)
 August 2014 (16)
 July 2014 (13)
 June 2014 (10)
 May 2014 (4)
 April 2014 (5)
 March 2014 (9)
 February 2014 (3)
 January 2014 (1)
 February 2013 (1)
 January 2013 (1)
 April 2012 (1)
 February 2012 (1)
 October 2011 (3)
 September 2011 (12)
 February 2006 (1)
 January 2006 (1)
Category Archives: Algorithms
Atlassian Hackerrank Interview
1) Implement a method ‘find’ that will find the starting index (zero based) where the second list occurs as a sublist in the first list. It should return 1 if the sublist cannot be found. Arguments are always given, not … Continue reading
Posted in Algorithms
Leave a comment
Combinations of a String
Implement a function that prints all possible combinations of a string. A string “12” is the same as string “21” function combine($instr, $outstr, $index) { for ($i = $index; $i < strlen($instr); $i++) { $outstr = $outstr . $instr[$i]; echo … Continue reading
Posted in Algorithms
Leave a comment
Given Array of positive negative numbers find 2,3 of them that sum to zero
Given an array of numbers with positive and negative, find pairs that sum to zero a) sort the numbers b) start 2 pointers from from begin and end c) if sum is > or < = then move appropriate … Continue reading
Posted in Algorithms
Leave a comment
Find if an integer is a prime number
The algorithm can be improved further by observing that all primes are of the form 6k ± 1, with the exception of 2 and 3. This is because all integers can be expressed as (6k + i) for some integer … Continue reading
Posted in Algorithms
Leave a comment
Trees: Find count of unival or single valued subtrees
http://www.geeksforgeeks.org/findcountofsinglysubtrees/
Posted in Algorithms
Leave a comment
Towers of Hanoi
https://www.youtube.com/watch?v=q6RicK1FCUs Karumanchi, pg 37.
Posted in Algorithms
Leave a comment
Sort an array of 0s, 1s and 2s
Given an array A[] consisting 0s, 1s and 2s, write a function that sorts A[]. The functions should put all 0s first, then all 1s and all 2s in last. Example Input = {0, 1, 1, 0, 1, 2, 1, … Continue reading
Posted in Algorithms
Leave a comment
Longest Common Subsequence
https://www.youtube.com/watch?v=NnD96abizww if (input1[i] == input2[j]) { M[i][j] = M[i1][j1] + 1 } else { M[i][j] = max(M[i1,j], M[i,j1]) }
Posted in Algorithms
Leave a comment
Sort Algorithms
Stable Sort: A sorting algorithm is said to be stable if two objects with equal keys appear in the same order in sorted output as they appear in the input unsorted array. Some sorting algorithms are stable by nature like … Continue reading
Posted in Algorithms
Leave a comment
Find kth largest element in an unsorted array
Method 1 (Simple Solution) A Simple Solution is to sort the given array using a O(nlogn) sorting algorithm like Merge Sort, Heap Sort, etc and return the element at index k1 in the sorted array. Time Complexity of this solution … Continue reading
Posted in Algorithms
Leave a comment