This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dailyprogrammer; | |
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
/** | |
* all permutations of a string / char array | |
* @author anupam | |
*/ | |
public class Problem6 { | |
public static ArrayList<String> allPerms(String str) { | |
ArrayList<String> al = new ArrayList<>(); | |
int i=0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jsobj = {'badjsobj':'bad'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var goodjsobj = {"goodjson":"good"}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine on | |
RewriteCond %{HTTP_HOST} ^anupamsblog.gear.host$ [OR] | |
RewriteCond %{HTTP_HOST} ^www.anupamsblog.gear.host" target="_blank">www.anupamsblog.gear.host$ | |
RewriteRule ^php$ http://anupamsblog.gear.host" target="_blank">http://anupamsblog.gear.host [R=301,L] | |
RewriteEngine on | |
RewriteCond %{HTTP_HOST} ^anupamsblog.gear.host$ [OR] | |
RewriteCond %{HTTP_HOST} ^www.anupamsblog.gear.host" target="_blank">www.anupamsblog.gear.host$ | |
RewriteRule ^share$ http://anupamsblog.gear.host" target="_blank">http://anupamsblog.gear.host [R=301,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def minCost(cost,N): | |
best_way_to_reach = [0]*N | |
for k in range(1,N): | |
minimum_cost_to_get_from_0_to_k = sys.maxint | |
for i in range(k,0,-1): | |
if(minimum_cost_to_get_from_0_to_k > best_way_to_reach[k-i]+cost[k-i][k]): | |
minimum_cost_to_get_from_0_to_k = best_way_to_reach[k-i]+cost[k-i][k] | |
best_way_to_reach[k] = min(minimum_cost_to_get_from_0_to_k,cost[0][k]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def numOfWaysToTgt(target,allowedUnits) | |
scores = Array.new(target+1,0) | |
scores[0] = 1 | |
allowedUnits.each do |allowedScore| | |
(allowedScore..target).each do |k| | |
scores[k] += scores[k-allowedScore] | |
end | |
end | |
puts "#{target} can be reached in #{scores[target]} ways" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Maximize number of 0s by flipping a subarray | |
// Given a binary array, find the maximum number zeros in an array with one flip of a subarray allowed. | |
// A flip operation switches all 0s to 1s and 1s to 0s. | |
// Examples: | |
// Input : arr[] = {0, 1, 0, 0, 1, 1, 0} | |
// Output : 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Maximize value of (arr[i] – i) – (arr[j] – j) in an array | |
// Given an array, arr[] find the maximum value of (arr[i] – i) – (arr[j] – j) where i is not equal to j. | |
// Where i and j vary from 0 to n-1 and n is size of input array arr[]. | |
// Examples: | |
// Input : arr[] = {9, 15, 4, 12, 13} | |
// Output : 12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check if string follows order of characters defined by a pattern or not | Set 2 | |
// Given an input string and a pattern, check if characters in the input string follows the same order as determined by characters present in the pattern. | |
// Assume there won’t be any duplicate characters in the pattern. | |
// Another solution to the same problem is posted here. | |
// Examples: |
OlderNewer