Print All Distinct Circular Strings of Length M in Lexicographical Order in C++

sudhir sharma
Updated on 22-Jan-2020 12:25:30

234 Views

In this problem, we are given a string and an integer M. our task is to print all distinct circular strings of length M in lexicographical order (alphabetical order).Let’s take an example to understand the problem, Input: str= “ssssn” M=3 Output: nss sns ssn sssExplanation − all possible circular strings of length 3 are: sss sss ssn sns nss. Distinct elements in lexicographical order are sss ssn sns nss.To solve this problem, we will iterate over the elements of the string and generate all possible substrings of length M. we will store this generated string in a set that stores ... Read More

Stop All Instances of a Process in PowerShell

Chirag Nagrekar
Updated on 22-Jan-2020 12:25:26

2K+ Views

To stop running all the instances of the process in PowerShell Stop-Process command is used. For example, in the below example, we have two running instances of notepad.exe process.CommandPS C:\WINDOWS\system32> Get-Process notepadOutputPS C:\WINDOWS\system32> Get-Process notepad Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName -------  ------    -----      -----     ------     --  -- -----------     228      13     3160      13448       0.14  15564   1 notepad     228      14     3148      13668       0.17  22644 ... Read More

Get Process Output in GridView Format in PowerShell

Chirag Nagrekar
Updated on 22-Jan-2020 12:24:51

700 Views

To get the output in gridview format in PowerShell, you need to Pipeline the Out-GridView variable so the output will be in GUI format.CommandGet-Process | Sort-Object CPU -Descending | Select -First 10 | Out-GridView -Title "Top 10 CPU usage processes"

Display a Few Numbers of Results in GET Process in PowerShell

Chirag Nagrekar
Updated on 22-Jan-2020 12:23:39

898 Views

To display only the first 5 processes you need to use –First parameter in the Select-Object pipeline statement. You can use multiple filter statements and later at last pipeline the –First command to display only a few results.CommandGet-Process | Select -First 5OutputHandles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName -------  ------    -----      -----     ------     --  -- -----------     498      26     9736      18624       2.27   6320   1 AcroRd32     624      51   112048 ... Read More

Get Process Properties Using PowerShell

Chirag Nagrekar
Updated on 22-Jan-2020 12:23:36

4K+ Views

Get-Process shows the default properties only. To get all the properties of Get-Process, we need to pipeline Format-List * (fl *).Get-Process | Format-List *OutputName                       : AcroRd32 Id                         : 8052 PriorityClass              : Normal FileVersion                : 11.0.23.22 HandleCount                : 616 WorkingSet                 : 17453056 PagedMemorySize            : 114597888 ... Read More

Print All Distinct Elements of a Given Integer Array in C++

sudhir sharma
Updated on 22-Jan-2020 12:22:59

850 Views

In this problem, we are given an array of integer values. Our task is to print all distinct elements of the array. The output should contain only distinct values.Let’s take an example to understand the problemInput: array = {1, 5, 7, 12, 1, 6, 10, 7, 5} Output: 1 5 7 12 6 10To solve this problem, we will have to check elements of the array for uniqueness. For this, we will use two nested loops, the outer one will take values and the inner one will check the rest of the values with it. If more than one values ... Read More

Group Processes by Name in PowerShell

Chirag Nagrekar
Updated on 22-Jan-2020 12:22:37

425 Views

You can group the processes based on their properties. Here, we will group the processes based on their name, it would display how many instances of the process is running. Group-Object command is useful for it.CommandThe below command will group the object and sort the object based on their thread counts.Get-Process |Group-Object Name | Select Name, Count |Sort-Object count - DescendingOutputName                                                           Count ----                                                           ----- svchost                                                           91 chrome                                                            34 RuntimeBroker                                                     11 conhost                                                            6 Code                                                               6 WmiPrvSE                                                           6 dllhost                                                            4 RAVBg64                                                            4 powershell                                                         3 csrss                                                              2 fontdrvhost                                                        2 AcroRd32                                                           2 taskhostw                                                          2 SkypeBridge                                                        1 smartscreen                                                        1 smss                                                               1 sihost                                                             1 SkypeApp                                                           1 SkypeBackgroundHost                                                1 sppsvc                                                             1 StartMenuExperienceHost                                            1

Get Specific Process Information Using PowerShell

Chirag Nagrekar
Updated on 22-Jan-2020 12:22:07

2K+ Views

To find the specific process using Get-Process cmdlet, you need to use the –Name parameter. You can use single and multiple process names.CommandGet-Process -Name AcroRd32, audiodgOutputHandles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName ------- ------ ----- ----- ------ -- -- ----------- 506 27 9888 19216 2.22 6320 1 AcroRd32 632 51 112196 17648 42.95 8052 1 AcroRd32 209 13 10344 17100 13.98 22748 0 audiodgYou can also achieve the same using Where-Object (alias: Where) command.Get-Process | Where{$_.Name -eq "AcroRd32"} But to get the multiple processes you need to use the –OR comparison operator.Get-Process | Where{($_.Name -eq "AcroRd32") -or ($_.Name -eq ... Read More

Sort Processes Based on Their Property Name Using PowerShell

Chirag Nagrekar
Updated on 22-Jan-2020 12:18:58

4K+ Views

To sort the processes based on their various property names, Sort-Object command needs to pipeline and property name should be entered followed by it to the Get-Process cmdlet or WMI class or CIM instance.CommandTo sort the property based on the CPU usage.Get-Process | Sort-Object CPUOutputHandles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName -------  ------    -----      -----     ------     --  -- -----------       0       0       60          8                 0 ... Read More

Print All Distinct Integers from K Numbers in C++

sudhir sharma
Updated on 22-Jan-2020 12:18:14

270 Views

In this problem, we are given an array of N integers and a number K. Our task is to print all distinct numbers that can be created by adding any K elements from the array. While choosing any number can be repeated K times.Let’s take an example to understand the problem −Input: array = {2, 5, 13, 9} K = 2 Output: 2, 7, 15, 11, 10, 18, 14, 26, 22 Explaination: 2 elements added : 2+2=4, 2+5=7, 2+13=15, 2+9=11, 5+5=10, 5+13=18, 5+9=14, 13+13=26, 13+9=22, 9+9=18To solve this problem, we will find all combinations of the k element from the ... Read More

Advertisements