Skip to main content

Posts

Showing posts with the label Problem & Solution Topics

System Design | Design Scalable Systems

✋System design is the process of designing the elements of a system such as the architecture, modules, and components, the different interfaces of those components, and the data that goes through that system. The purpose of the System Design process is to provide sufficient detailed data and information about the system and its system elements to enable the implementation consistent with architectural entities as defined in models and views of the system architecture. 1) Requirements Clarification: the beginning point of software development activity. Software requirement is one such area to which little importance was attached in the early days of software development, as the emphasis was on coding and design. The main assumption was that the developers understood the problem clearly when it was explained to them, generally informally. Therefore, the need for a more rigorous requirement analysis phase arose. Now, for large systems 2) System Interface Definition: Int...

Sliding Window Maximum (Maximum of all subarrays of size k) Using Golang

Given an array and an integer k, find the maximum for each and every contiguous subarray of size k. Examples : Input : arr[] = {1, 2, 3, 1, 4, 5, 2, 3, 6} k = 3 Output : 3 3 4 5 5 5 6 package main import "fmt" var n int func main() { k := 3 s := []int{1, 2, 3, 1, 4, 5, 2, 3, 6} n = k slidingWindowMaximum(s, 0, k) } func slidingWindowMaximum(arr []int, i int, k int) { //Check Array size greater then k or not ! if len(arr) < k { return } // Find Max Value in Sub Arrays max := 0 for ; i < k; i++ { //Find Max Value max = findmax(max, arr[i]) } //Print Max Sub Arrays Element fmt.Print(max, " ") //Find in next Sub Arrays in Max Call function slidingWindowMaximum(arr, i-n+1, k+1) } func findmax(a int, b int) int { if a < b { return b } else { return a } }

Java String Tokens | Regex expression

Given a string,  , matching the regular expression  [A-Za-z !,?._'@]+ , split the string into  tokens . We define a token to be one or more consecutive English alphabetic letters. Then, print the number of tokens, followed by each token on a new line. Note:  You may find the  String.split  method helpful in completing this challenge. Input Format A single string,  . Constraints  is composed of  any  of the following: English alphabetic letters, blank spaces, exclamation points ( ! ), commas ( , ), question marks ( ? ), periods ( . ), underscores ( _ ), apostrophes ( ' ), and at symbols ( @ ). Output Format On the first line, print an integer,  , denoting the number of tokens in string   (they  do not  need to be unique). Next, print each of the   tokens on a new line in the same order as they appear in input string  . Sample Input He is a very...

Java Anagrams

Two strings,   and  , are called anagrams if they contain all the same characters in the same frequencies. For example, the anagrams of  CAT  are  CAT ,  ACT ,  TAC ,  TCA ,  ATC , and  CTA . Complete the function in the editor. If   and   are case-insensitive anagrams, print "Anagrams"; otherwise, print "Not Anagrams" instead. Input Format The first line contains a string denoting  . The second line contains a string denoting  . Constraints Strings   and   consist of English alphabetic characters. The comparison should NOT be case sensitive. Output Format Print "Anagrams" if   and   are case-insensitive anagrams of each other; otherwise, print "Not Anagrams" instead. Sample Input 0 anagram margana Sample Output 0 Anagrams Explanation 0 Character Frequency:  anagram Freque...