Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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.
- */
- package code;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.HashMap;
- import java.util.LinkedHashMap;
- import java.util.LinkedList;
- import java.util.List;
- import java.util.Scanner;
- /**
- *
- * @author manth
- */
- public class Code {
- /**
- * @param args the command line arguments
- */
- /*
- Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.
- Strings consists of lowercase English letters only and the length of both strings s and p will not be larger than 20,100.
- The order of output does not matter.
- Example 1:
- Input:
- s: "cbaebabacd" p: "abc"
- Output:
- [0, 6]
- Explanation:
- The substring with start index = 0 is "cba", which is an anagram of "abc".
- The substring with start index = 6 is "bac", which is an anagram of "abc".
- */
- static int [][] sc=new int [25][25];
- public static void main(String[] args) {
- Scanner sc1=new Scanner(System.in);
- //String s=sc1.nextLine();
- System.out.println(ways(6));
- }
- static HashMap<Integer,Integer> ways_cents=new HashMap<>();
- public static int ways (int cents)
- {
- if(cents<0)
- return 0;
- if(cents==0)
- return 1;
- if(ways_cents.get(cents)!=null)
- {
- return ways_cents.get(cents);
- }
- else
- {
- int count=(ways(cents-25)+ways(cents-10)+ways(cents-5)+ways(cents-1));
- ways_cents.put(cents, count);
- return count;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment