Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Server Side Programming Articles - Page 1903 of 2650
610 Views
Suppose the set is like [1, 2, 3, ..., n], contains a total of n! unique permutations. By listing and labeling all of the permutations in order, we get these sequence for n = 3: ["123", "132", "213", "231", "312", "321"] So if n and k are given, then return the kth permutation sequence. The n will be between 1 to 9 (inclusive) and k will be between 1 to n! (inclusive). For example if n = 3.Let us see the steps −ans := empty string, define array called candidates of size nfor i in range 0 to n – ... Read More
2K+ Views
Suppose we have a positive integer n, we have to generate a square matrix with n2 elements in spiral order. So if n = 5, then the matrix will be −12341213145111615610987Let us see the steps −set (row1, col1) := (0, 0) and (row2, col2) := (n, n), and create one matrix called res, then fill it with 0s, and set num := 1while num n2, then breakfor i in range row1 + 1 to row2, res[i, col2-1] = num, incase num by 1if num > n2, then breakfor i in range col2 – 2 down to col1 – 1, ... Read More
1K+ Views
Suppose we have a collection of intervals, we have to merge all overlapping intervals. So if the intervals are like [[1, 3], [2, 6], [8, 10], [15, 18]], then the intervals after merging will be [[1, 6], [8, 10], [15, 18]]. This is because there were two intervals those are overlapping, the intervals are [1, 3] and [2, 6], these are merged to [1, 6]Let us see the steps −if interval list length is 0, then return a blank listsort the interval list using quicksort mechanismstack := an empty stack, and insert intervals[0] into the stackfor i in range 1 ... Read More
3K+ Views
Suppose we have an array of non-negative integers; we are initially positioned at the first index of the array. Each element in the given array represents out maximum jump length at that position. We have to determine if we are able to reach the last index or not. So if the array is like [2, 3, 1, 1, 4], then the output will be true. This is like jump one step from position 0 to 1, then three step from position 1 to the end.Let us see the steps −n := length of array A – 1for i := n ... Read More
498 Views
Suppose we have a set of candidate numbers (all elements are unique) and a target number. We have to find all unique combinations in candidates where the candidate numbers sum to the given target. The same number will not be chosen from candidates more than once. So if the elements are [2, 3, 6, 7, 8] and the target value is 8, then the possible output will be [[2, 6], [8]]Let us see the steps −We will solve this in recursive manner. The recursive function is named as solve(). This takes index, an array a, the integer b and another ... Read More
2K+ Views
Suppose we have a set of candidate numbers (all elements are unique) and a target number. We have to find all unique combinations in candidates where the candidate numbers sum to the given target. The same repeated number may be chosen from candidates unlimited number of times. So if the elements are [2, 3, 6, 7] and the target value is 7, then the possible output will be [[7], [2, 2, 3]]Let us see the steps −We will solve this in recursive manner. The recursive function is named as solve(). This takes an array to store results, one map to ... Read More
4K+ Views
Suppose we want to implement the next permutation method, that method rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, this method will rearrange it as the lowest possible order (That is actually, sorted in ascending order). The replacement must be in-place and do not use any extra memory. For example, if the Inputs are in the left-hand column and its corresponding outputs are in the right-hand column.1, 2, 3 → 1, 3, 2 3, 2, 1 → 1, 2, 3 1, 1, 5 → 1, 5, 1Let us see the steps −found ... Read More
3K+ Views
Tkinter is the standard GUI library for Python. Python when combined with Tkinter provides a fast and easy way to create GUI applications. Tkinter provides a powerful object-oriented interface to the Tk GUI toolkit.Creating a GUI application using Tkinter is an easy task. All you need to do is perform the following steps −Import the Tkinter module.Create the GUI application main window.Add one or more of the above-mentioned widgets to the GUI application.Enter the main event loop to take action against each event triggered by the user.Example#!/usr/bin/python import Tkinter top = Tkinter.Tk() # Code to add widgets will go here... top.mainloop()This would ... Read More
2K+ Views
The Document Object Model ("DOM") is a cross-language API from the World Wide Web Consortium (W3C) for accessing and modifying XML documents.The DOM is extremely useful for random-access applications. SAX only allows you a view of one bit of the document at a time. If you are looking at one SAX element, you have no access to another.Here is the easiest way to quickly load an XML document and to create a minidom object using the xml.dom module. The minidom object provides a simple parser method that quickly creates a DOM tree from the XML file.The sample phrase calls the ... Read More
8K+ Views
SAX is a standard interface for event-driven XML parsing. Parsing XML with SAX generally requires you to create your own ContentHandler by subclassing xml.sax.ContentHandler.Your ContentHandler handles the particular tags and attributes of your flavor(s) of XML. A ContentHandler object provides methods to handle various parsing events. Its owning parser calls ContentHandler methods as it parses the XML file.The methods startDocument and endDocument are called at the start and the end of the XML file. The method characters(text) is passed character data of the XML file via the parameter text.The ContentHandler is called at the start and end of each element. If the parser is not in namespace mode, ... Read More