Tushar Goel

Ranch Hand
+ Follow
since Dec 29, 2013
Cows and Likes
Cows
Total received
4
In last 30 days
0
Total given
0
Likes
Total received
51
Received in last 30 days
0
Total given
54
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tushar Goel

Vaibhav Gargs wrote:We have to cache some data to improve the performance. The application will be deployed in multiple clusters. Which cache will be better to use here: Redis or Memcache?



Do you want to persist the cached data in storage as well. If yes, i think Redis is the option. Memcache is pure cache, it doesn't provide feature of persisting data.
2 months ago

Campbell Ritchie wrote:Please provide more details; the screenshots aren't opening correctly.



I guess someone corrected or it got automatically corrected.. Thanks whoever did this.
2 months ago

Liutauras Vilda wrote:@OP

Are you able to share the interview question details as well as your solution? Please double check in their policy.



no policies was mentioned.
2 months ago
Hi,

Recently i have given an interview in which i asked to design a system (as per screenshot).. I am unable to design and failed to think from where to start.. can anyone suggest?

Or you can see on my github link




2 months ago

Does updating version number here `<version>1.3.3.RELEASE</version>` and here `<version>4.2.5.RELEASE</version>` for the dependency good enough to use the latest version of Spring boot? OR is it going to break things?



Yes by updating to higher version may break things.
10 months ago
you need to add spring-web dependency

<!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-web</artifactId>
   <version>5.1.0.RELEASE</version>
</dependency>
11 months ago

Stephan van Hulst wrote:
strings.collect(
 Collectors.groupingBy(
   string -> Arrays.asList(
     string.codePoints().sorted().toArray()
   )
 )
)
[/code]



Sorry but it is giving me compilation error. What i am doing wrong here?

words.stream().collect(
            Collectors.groupingBy(
                s -> Arrays.asList(
                                   s.codePoints().sorted.toArray()
                       )
               )
       );
1 year ago
actually it teaches me 1 more thing.. importance of pencil and paper before jumping over the code..

I will try next time to emulate the steps on paper first..
1 year ago
@Piet, Thanks for the nice and detailed explanation.. I have understood every single step you tried....

I was missing condition where i need to reset if from goes negative.. Anyway it was cool .. Thanks Again...


@Liutauras Vilda, Sorry for the confusion.. It was long time i have not involved in any serious coding.. So, i miss many points... Anyway, i am back now
and will have more discussion in coming days.. Sorry again for the confusion..
1 year ago

Jeanne Boyarsky wrote:Tushar,



So simple and i made it overly complicated... aha...

You are genius. anyway it is good learning for developing better coding.. Thanks...
1 year ago
So , i have updated my main method by adding some print statements. Hope it helps to understand what i am getting:



My Software class:



The output looks like as below:


printing file contents
[Software [osName=Linux, softwareName=winscp, version=9.0], Software [osName=Linux, softwareName=winscp, version=10.0], Software [osName=Linux, softwareName=notepad++, version=11.0], Software [osName=Linux, softwareName=java, version=6.0], Software [osName=Ubuntu, softwareName=winscp, version=9.9], Software [osName=Ubuntu, softwareName=notepad++, version=11.1], Software [osName=Ubuntu, softwareName=notepad++, version=10.0], Software [osName=Ubuntu, softwareName=java, version=7.0], Software [osName=Windowa, softwareName=winscp, version=10.1], Software [osName=Windowa, softwareName=notepad++, version=10.0], Software [osName=Windowa, softwareName=java, version=8.0], Software [osName=MAC, softwareName=winscp, version=7.0], Software [osName=MAC, softwareName=notepad++, version=9.0], Software [osName=MAC, softwareName=java , version=10.0]]
------------------------
printing contents of the map grouped by OS

{Ubuntu={java=[Software [osName=Ubuntu, softwareName=java, version=7.0]], winscp=[Software [osName=Ubuntu, softwareName=winscp, version=9.9]], notepad++=[Software [osName=Ubuntu, softwareName=notepad++, version=11.1], Software [osName=Ubuntu, softwareName=notepad++, version=10.0]]},

Linux={java=[Software [osName=Linux, softwareName=java, version=6.0]], winscp=[Software [osName=Linux, softwareName=winscp, version=9.0], Software [osName=Linux, softwareName=winscp, version=10.0]], notepad++=[Software [osName=Linux, softwareName=notepad++, version=11.0]]},

Windowa={java=[Software [osName=Windowa, softwareName=java, version=8.0]], winscp=[Software [osName=Windowa, softwareName=winscp, version=10.1]], notepad++=[Software [osName=Windowa, softwareName=notepad++, version=10.0]]},

MAC={winscp=[Software [osName=MAC, softwareName=winscp, version=7.0]], java =[Software [osName=MAC, softwareName=java , version=10.0]], notepad++=[Software [osName=MAC, softwareName=notepad++, version=9.0]]}}
------------------------
printing contents of the map grouped by software in a OS

[{java=[Software [osName=Ubuntu, softwareName=java, version=7.0]], winscp=[Software [osName=Ubuntu, softwareName=winscp, version=9.9]], notepad++=[Software [osName=Ubuntu, softwareName=notepad++, version=11.1], Software [osName=Ubuntu, softwareName=notepad++, version=10.0]]},

{java=[Software [osName=Linux, softwareName=java, version=6.0]], winscp=[Software [osName=Linux, softwareName=winscp, version=9.0], Software [osName=Linux, softwareName=winscp, version=10.0]], notepad++=[Software [osName=Linux, softwareName=notepad++, version=11.0]]},

{java=[Software [osName=Windowa, softwareName=java, version=8.0]], winscp=[Software [osName=Windowa, softwareName=winscp, version=10.1]], notepad++=[Software [osName=Windowa, softwareName=notepad++, version=10.0]]},

{winscp=[Software [osName=MAC, softwareName=winscp, version=7.0]], java =[Software [osName=MAC, softwareName=java , version=10.0]], notepad++=[Software [osName=MAC, softwareName=notepad++, version=9.0]]}]
------------------------

is there any winscp version older than 9?
Software [osName=MAC, softwareName=winscp, version=7.0]
1 year ago
So, guys, i have just completed online course on Java 8. So to test my knowledge i got following question from my colleague:

We have a csv file in which 3 fields are their. 1) osName 2) Software 3) version

So we need to return outdated software version. User will provide the software and version name. File looks like as below:




So, after spending few hours i come up with the solution but its looking very much complicated. Any idea how to improve it further:

1 year ago

Carey Brown wrote:

Tushar Goel wrote:Meantime,i found another solution by recursive calls as mentioned in Programming Pearls.


I'm curious. Could you post your code for that?



Here is the code, i have implemented:




Actually in this we reverse array 3 times:
1) 0 to n-d-1 times  //so first time this reverse the array of length n-d
2) n-d to n times   //this will reverse the array of d length from end
3) 0 to n times // this again reverse the array so that elements comes to their position
1 year ago

Piet Souris wrote:I totally underestimated the role of GCD. That made me having to save 'Shift' numbers, instead of just 1. Clever guys, these GeeksForGeeks!

But I never like methods that do a lot of this index juggling. It is often difficult to get it right and makes the code hard to follow. I mentioned a method in the Collections class, that we can use to let Java do all the hard work. The two problems (what are problems?) are that that method works with Lists, and therefore leaves the input array unmodified. But suppose we have two methods: List arrayToList(int[] array' and 'int[] listToArray(List list)' we could have:

And 'shift' can be positive or negative, to detrmine the direction of the shift.



Actually i have checked Java 7 rotate method as well.. Internally they are using separate list to perform rotate but sometimes, we have to give a solution which is in place and takes constant memory.

But still i am unable to find out the problem in my original code. Not sure where i am wrong in that solution.

Meantime,i found another solution by recursive calls as mentioned in Programming Pearls.
1 year ago

Carey Brown wrote:




WOW.... it is so easy. I have not think that way. It can be done this way as well.... I have spent 2 days on it and solution was so simple...
Thank you...
1 year ago