Find all permutations of a String

Given a string, find all the permutations of the string. For example: Input String: abc Output: {bca, acb, abc, cba, bac, cab} Program: class Program { /*Function to print permutations of string This function takes three parameters: 1. String 2. Starting index of the string 3. Ending index of the string.*/ private static void permute(String […]

Read More

Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit. Note: you cannot sell a stock […]

Read More

Maximum Subarray

Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 // C# program to print largest contiguous array sum class Program { static int maxSubArraySum(int[] a) { int size = a.Length; int max_so_far = int.MinValue, max_ending_here = […]

Read More

Anagram

Two strings are said to be anagrams, if one string can be obtained by rearranging the letters of another. Examples: dog, god abac, baac anagram, nagaram silent, listen class Anagram { public static void IsAnagram(string word1, string word2) { bool flag = true; if (word1.Length != word1.Length) { flag = false; } var aFrequency = […]

Read More

Text Translation with Google Translate API in Python

Unless you have been hiding under a rock, you have probably used Google Translate on many occasions in your life. Whenever you try to translate a word or a sentence from a certain language to another, it is the Google Translate API which brings you the desired results in the background. Though you can translate anything by […]

Read More

Array vs Linked List

Arrays and Linked Lists both are linear data structures, but they both have some advantages and disadvantages over each other. One advantage of the linked list is that elements can be added to it indefinitely, while an array will eventually get filled or have to be resized (a costly operation that isn’t always possible). Elements […]

Read More

Top 10 largest Auto Insurance Companies of 2020

In USA the top ten auto insurance companies control approximately 72% of the market.   Do You Know the Top 10 largest Auto Insurance Companies of 2020? When looking at the rankings of the top auto insurance companies in the United States, most of the names are recognizable due to their national television advertising campaigns. […]

Read More