New answers tagged

1

Your code does what you describe, but the code does not what it is really supposed to do. You are not the first person ever who needs to convert an arbitrary string into a form that can be embedded in a URL. Several people before you have already solved this problem. The crucial point is to know how these people named the method or function or class or ...


1

Review Welcome to Code Review. There are some suggestions as follows. Consider to use replaceAll The operation you performed is what String.replaceAll do, you can use replaceAll directly instead of String.toCharArray(), whitespace comparison, and sb.append things. Create a method URLify In order to improve usability, it is better to create a method URLify to ...


2

If you are in an interview using Python, assume that the interviewer is reasonable and wants you to write fluent Python code. That means, among other things, taking advantage of the language's built-in powers: def defrang(ip): return ip.replace('.', '[.]') But let's suppose that the interviewer explicitly directs you to ignore built-ins and write your ...


0

I'm not super familiar with Catan, having played it only once in my life and not even to completion, but a grid's a grid, and hex grids can be modeled using three axes instead of the usual two. The data structure you're searching for is an Array. (Or a Vector, if you wanna get fancy with mutability.) Before I get to the demo, just a few notes on your various ...


Top 50 recent answers are included